-
Notifications
You must be signed in to change notification settings - Fork 1
120 lines (110 loc) · 4.38 KB
/
deploy-prod&demo.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
name: Deploy to production and demo
on:
push:
branches:
- main
workflow_dispatch:
jobs:
test:
name: Test and build
if: github.event.pull_request.draft == false
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
changed: ${{ steps.set-matrix.outputs.changed }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# We need to fetch all branches and commits so that Nx affected has a base to compare against.
fetch-depth: 0
- uses: nrwl/nx-set-shas@v4
- run: yarn install --frozen-lockfile
- name: Caching Nx
uses: actions/cache@v4
with:
path: node_modules/.cache
key: cache-nx-${{ hashFiles('yarn.lock') }}
- id: set-matrix
run: |
echo "matrix={\"appname\":$(yarn --silent run matrix)}" >> $GITHUB_OUTPUT
echo "changed=$(yarn --silent run matrix)" >> $GITHUB_OUTPUT
- run: yarn playwright install
- run: yarn run affected:lint --parallel=2
- run: yarn run affected:test --configuration=ci --parallel=2
- run: yarn run affected:e2e --configuration=ci --parallel=1
env:
E2E_AUTH_ADMIN_ID: ${{ secrets.E2E_AUTH_ADMIN_ID }}
E2E_AUTH_READ_ID: ${{ secrets.E2E_AUTH_READ_ID }}
E2E_AUTH_WRITE_ID: ${{ secrets.E2E_AUTH_WRITE_ID }}
E2E_CATALOG_ID: ${{ secrets.E2E_CATALOG_ID }}
E2E_KEYCLOAK_ID_SERVICE_CATALOG_FRONTEND: ${{ secrets.E2E_KEYCLOAK_ID_SERVICE_CATALOG_FRONTEND }}
E2E_KEYCLOAK_SECRET_SERVICE_CATALOG_FRONTEND: ${{ secrets.E2E_KEYCLOAK_SECRET_SERVICE_CATALOG_FRONTEND }}
E2E_KEYCLOAK_ID_CATALOG_PORTAL_FRONTEND: ${{ secrets.E2E_KEYCLOAK_ID_CATALOG_PORTAL_FRONTEND }}
E2E_KEYCLOAK_SECRET_CATALOG_PORTAL_FRONTEND: ${{ secrets.E2E_KEYCLOAK_SECRET_CATALOG_PORTAL_FRONTEND }}
E2E_NEXTAUTH_SECRET: ${{ secrets.E2E_NEXTAUTH_SECRET }}
- name: Merge CTRF reports
run: npx ctrf merge reports
if: ${{ hashFiles('reports/') != '' }}
- name: Run CTRF annotations
run: npx github-actions-ctrf reports/ctrf-report.json
if: ${{ hashFiles('reports/') != '' }}
- run: yarn run affected:build --configuration=ci --parallel=2
- name: Caching Dist Folder
uses: actions/cache@v4
with:
path: ./dist
key: cache-dist-${{ github.sha }}
build:
name: Build affected apps when pull request is created
needs: [test]
if: ${{ needs.test.outputs.changed != '[]' }}
strategy:
matrix: ${{fromJSON(needs.test.outputs.matrix)}}
uses: Informasjonsforvaltning/workflows/.github/workflows/build-push.yaml@main
with:
app_name: ${{ matrix.appname }}-frontend
monorepo_app: true
environment: prod
build_env: true
build_env_name: BINARY
build_env_value: ${{ matrix.appname }}-frontend
cache_path: ./dist
cache_key: cache-dist-${{ github.sha }}
dockerfile: apps/${{ matrix.appname }}/Dockerfile
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy-prod:
name: Deploy affected apps to production environment with reusable workflow
needs: [test, build]
strategy:
matrix: ${{fromJSON(needs.test.outputs.matrix)}}
fail-fast: false
if: ${{ needs.test.outputs.changed != '[]' }}
uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main
with:
app_name: ${{ matrix.appname }}-frontend
environment: prod
monorepo_app: true
cluster: digdir-fdk-prod
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DIGDIR_FDK_AUTODEPLOY: ${{ secrets.DIGDIR_FDK_PROD_AUTODEPLOY }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
deploy-demo:
name: Deploy affected apps to demo environment with reusable workflow
needs: [test, deploy-prod]
strategy:
matrix: ${{fromJSON(needs.test.outputs.matrix)}}
fail-fast: false
if: ${{ needs.test.outputs.changed != '[]' }}
uses: Informasjonsforvaltning/workflows/.github/workflows/kustomize-deploy.yaml@main
with:
app_name: ${{ matrix.appname }}-frontend
environment: demo
monorepo_app: true
cluster: digdir-fdk-dev
secrets:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DIGDIR_FDK_AUTODEPLOY: ${{ secrets.DIGDIR_FDK_DEV_AUTODEPLOY }}
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}