|
1 | 1 | name: Build docker image
|
2 | 2 | on:
|
3 |
| - workflow_call: |
4 |
| - inputs: |
5 |
| - environment: |
6 |
| - required: true |
7 |
| - type: string |
8 |
| - imagename: |
9 |
| - required: true |
10 |
| - type: string |
11 |
| - ENV: |
12 |
| - required: true |
13 |
| - type: string |
14 |
| - ADMIN_ORIGIN: |
15 |
| - required: true |
16 |
| - type: string |
17 |
| - APP_ORIGIN: |
18 |
| - required: true |
19 |
| - type: string |
20 |
| - REVALIDATOR_PROXY_ORIGIN: |
21 |
| - required: true |
22 |
| - type: string |
23 |
| - DECORATOR_URL: |
24 |
| - required: true |
25 |
| - type: string |
26 |
| - XP_ORIGIN: |
27 |
| - required: true |
28 |
| - type: string |
29 |
| - TELEMETRY_URL: |
30 |
| - required: true |
31 |
| - type: string |
32 |
| - INNLOGGINGSSTATUS_URL: |
33 |
| - required: true |
34 |
| - type: string |
35 |
| - MELDEKORT_API_URL: |
36 |
| - required: true |
37 |
| - type: string |
38 |
| - NAVNO_SEARCH_API_URL: |
39 |
| - required: true |
40 |
| - type: string |
41 |
| - FAILOVER_ORIGIN: |
42 |
| - required: true |
43 |
| - type: string |
44 |
| - RELEASE_TAG: |
45 |
| - required: false |
46 |
| - type: string |
47 |
| - IS_FAILOVER_INSTANCE: |
48 |
| - required: false |
49 |
| - type: boolean |
50 |
| - NODE_ENV: |
51 |
| - required: true |
52 |
| - type: string |
53 |
| - secrets: |
54 |
| - READER_TOKEN: |
55 |
| - required: true |
56 |
| - SERVICE_SECRET: |
57 |
| - required: false |
58 |
| - NAIS_WORKLOAD_IDENTITY_PROVIDER: |
59 |
| - required: true |
60 |
| - outputs: |
61 |
| - image: |
62 |
| - description: "Url to docker image" |
63 |
| - value: ${{ jobs.build_image.outputs.image }} |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + environment: |
| 6 | + required: true |
| 7 | + type: string |
| 8 | + imagename: |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + ENV: |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + ADMIN_ORIGIN: |
| 15 | + required: true |
| 16 | + type: string |
| 17 | + APP_ORIGIN: |
| 18 | + required: true |
| 19 | + type: string |
| 20 | + REVALIDATOR_PROXY_ORIGIN: |
| 21 | + required: true |
| 22 | + type: string |
| 23 | + DECORATOR_URL: |
| 24 | + required: true |
| 25 | + type: string |
| 26 | + XP_ORIGIN: |
| 27 | + required: true |
| 28 | + type: string |
| 29 | + TELEMETRY_URL: |
| 30 | + required: true |
| 31 | + type: string |
| 32 | + INNLOGGINGSSTATUS_URL: |
| 33 | + required: true |
| 34 | + type: string |
| 35 | + MELDEKORT_API_URL: |
| 36 | + required: true |
| 37 | + type: string |
| 38 | + NAVNO_SEARCH_API_URL: |
| 39 | + required: true |
| 40 | + type: string |
| 41 | + FAILOVER_ORIGIN: |
| 42 | + required: true |
| 43 | + type: string |
| 44 | + RELEASE_TAG: |
| 45 | + required: false |
| 46 | + type: string |
| 47 | + IS_FAILOVER_INSTANCE: |
| 48 | + required: false |
| 49 | + type: boolean |
| 50 | + NODE_ENV: |
| 51 | + required: true |
| 52 | + type: string |
| 53 | + secrets: |
| 54 | + READER_TOKEN: |
| 55 | + required: true |
| 56 | + SERVICE_SECRET: |
| 57 | + required: false |
| 58 | + NAIS_WORKLOAD_IDENTITY_PROVIDER: |
| 59 | + required: true |
| 60 | + outputs: |
| 61 | + image: |
| 62 | + description: 'Url to docker image' |
| 63 | + value: ${{ jobs.build_image.outputs.image }} |
64 | 64 |
|
65 | 65 | jobs:
|
66 |
| - build_image: |
67 |
| - name: Build docker image |
68 |
| - runs-on: ubuntu-latest |
69 |
| - permissions: |
70 |
| - contents: "read" |
71 |
| - id-token: "write" |
72 |
| - environment: ${{ inputs.environment }} |
73 |
| - outputs: |
74 |
| - image: ${{ steps.docker-push.outputs.image }} |
75 |
| - steps: |
76 |
| - - name: Checkout repo |
77 |
| - uses: actions/checkout@v4 |
78 |
| - - name: Setup node.js |
79 |
| - uses: actions/setup-node@v4 |
80 |
| - with: |
81 |
| - node-version: '20' |
82 |
| - registry-url: 'https://npm.pkg.github.com' |
83 |
| - cache: 'npm' |
84 |
| - - name: Set app environmment |
85 |
| - run: | |
86 |
| - cat > .env <<EOF |
87 |
| - ENV=${{ inputs.ENV }} |
88 |
| - NODE_ENV=${{ inputs.NODE_ENV }} |
89 |
| - ADMIN_ORIGIN=${{ inputs.ADMIN_ORIGIN }} |
90 |
| - APP_ORIGIN=${{ inputs.APP_ORIGIN }} |
91 |
| - DECORATOR_URL=${{ inputs.DECORATOR_URL }} |
92 |
| - XP_ORIGIN=${{ inputs.XP_ORIGIN }} |
93 |
| - TELEMETRY_URL=${{ inputs.TELEMETRY_URL }} |
94 |
| - REVALIDATOR_PROXY_ORIGIN=${{ inputs.REVALIDATOR_PROXY_ORIGIN }} |
95 |
| - FAILOVER_ORIGIN=${{ inputs.FAILOVER_ORIGIN }} |
96 |
| - IS_FAILOVER_INSTANCE=${{ inputs.IS_FAILOVER_INSTANCE }} |
97 |
| - INNLOGGINGSSTATUS_URL=${{ inputs.INNLOGGINGSSTATUS_URL }} |
98 |
| - NAVNO_SEARCH_API_URL=${{ inputs.NAVNO_SEARCH_API_URL }} |
99 |
| - MELDEKORT_API_URL=${{ inputs.MELDEKORT_API_URL }} |
100 |
| - ASSET_PREFIX=https://cdn.nav.no/personbruker/nav-enonicxp-frontend |
101 |
| - IMAGE_CACHE_DIR=/tmp/images |
102 |
| - NEXT_TELEMETRY_DISABLED=1 |
103 |
| - EOF |
104 |
| - - name: Nextjs cache |
105 |
| - uses: actions/cache@v4 |
106 |
| - with: |
107 |
| - path: ${{ github.workspace }}/.next/cache |
108 |
| - key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }} |
109 |
| - - name: Install dependencies |
110 |
| - run: npm ci |
111 |
| - env: |
112 |
| - NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} |
113 |
| - - name: Run linting |
114 |
| - run: npm run lint |
115 |
| - - name: Run tests |
116 |
| - run: npm run test |
117 |
| - - name: Build application |
118 |
| - run: npm run build |
119 |
| - env: |
120 |
| - SERVICE_SECRET: ${{ secrets.SERVICE_SECRET }} |
121 |
| - - name: Upload static files to Nav CDN |
122 |
| - uses: nais/deploy/actions/cdn-upload/v2@master |
123 |
| - with: |
124 |
| - team: personbruker |
125 |
| - source: ./.next/static |
126 |
| - destination: nav-enonicxp-frontend/_next |
127 |
| - project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} |
128 |
| - identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} |
129 |
| - - name: Build and push docker image |
130 |
| - uses: nais/docker-build-push@v0 |
131 |
| - id: docker-push |
132 |
| - with: |
133 |
| - team: personbruker |
134 |
| - project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} |
135 |
| - identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} |
136 |
| - image_suffix: ${{ inputs.imagename }} |
| 66 | + build_image: |
| 67 | + name: Build docker image |
| 68 | + runs-on: ubuntu-latest |
| 69 | + permissions: |
| 70 | + contents: read |
| 71 | + id-token: write |
| 72 | + environment: ${{ inputs.environment }} |
| 73 | + outputs: |
| 74 | + image: ${{ steps.docker-push.outputs.image }} |
| 75 | + steps: |
| 76 | + - name: Checkout repo |
| 77 | + uses: actions/checkout@v4 |
| 78 | + - name: Setup node.js |
| 79 | + uses: actions/setup-node@v4 |
| 80 | + with: |
| 81 | + node-version: 20 |
| 82 | + registry-url: 'https://npm.pkg.github.com' |
| 83 | + cache: 'npm' |
| 84 | + - name: Set app environmment |
| 85 | + run: | |
| 86 | + cat > .env <<EOF |
| 87 | + ENV=${{ inputs.ENV }} |
| 88 | + NODE_ENV=${{ inputs.NODE_ENV }} |
| 89 | + ADMIN_ORIGIN=${{ inputs.ADMIN_ORIGIN }} |
| 90 | + APP_ORIGIN=${{ inputs.APP_ORIGIN }} |
| 91 | + DECORATOR_URL=${{ inputs.DECORATOR_URL }} |
| 92 | + XP_ORIGIN=${{ inputs.XP_ORIGIN }} |
| 93 | + TELEMETRY_URL=${{ inputs.TELEMETRY_URL }} |
| 94 | + REVALIDATOR_PROXY_ORIGIN=${{ inputs.REVALIDATOR_PROXY_ORIGIN }} |
| 95 | + FAILOVER_ORIGIN=${{ inputs.FAILOVER_ORIGIN }} |
| 96 | + IS_FAILOVER_INSTANCE=${{ inputs.IS_FAILOVER_INSTANCE }} |
| 97 | + INNLOGGINGSSTATUS_URL=${{ inputs.INNLOGGINGSSTATUS_URL }} |
| 98 | + NAVNO_SEARCH_API_URL=${{ inputs.NAVNO_SEARCH_API_URL }} |
| 99 | + MELDEKORT_API_URL=${{ inputs.MELDEKORT_API_URL }} |
| 100 | + ASSET_PREFIX=https://cdn.nav.no/personbruker/nav-enonicxp-frontend |
| 101 | + IMAGE_CACHE_DIR=/tmp/images |
| 102 | + NEXT_TELEMETRY_DISABLED=1 |
| 103 | + EOF |
| 104 | + - name: Nextjs cache |
| 105 | + uses: actions/cache@v4 |
| 106 | + with: |
| 107 | + path: ${{ github.workspace }}/.next/cache |
| 108 | + key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }} |
| 109 | + - name: Install dependencies |
| 110 | + run: npm ci |
| 111 | + env: |
| 112 | + NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} |
| 113 | + - name: Run linting |
| 114 | + run: npm run lint |
| 115 | + - name: Run tests |
| 116 | + run: npm run test |
| 117 | + - name: Build application |
| 118 | + run: npm run build |
| 119 | + env: |
| 120 | + SERVICE_SECRET: ${{ secrets.SERVICE_SECRET }} |
| 121 | + - name: Upload static files to Nav CDN |
| 122 | + uses: nais/deploy/actions/cdn-upload/v2@master |
| 123 | + with: |
| 124 | + team: personbruker |
| 125 | + source: ./.next/static |
| 126 | + destination: nav-enonicxp-frontend/_next |
| 127 | + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} |
| 128 | + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} |
| 129 | + - name: Build and push docker image |
| 130 | + uses: nais/docker-build-push@v0 |
| 131 | + id: docker-push |
| 132 | + with: |
| 133 | + team: personbruker |
| 134 | + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} |
| 135 | + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} |
| 136 | + image_suffix: ${{ inputs.imagename }} |
0 commit comments