|
1 | 1 | name: Build and deploy XP archive
|
2 | 2 | on:
|
3 |
| - workflow_call: |
4 |
| - inputs: |
5 |
| - naisEnv: |
6 |
| - required: true |
7 |
| - type: string |
8 |
| - VITE_APP_ORIGIN: |
9 |
| - required: true |
10 |
| - type: string |
11 |
| - XP_ORIGIN: |
12 |
| - required: true |
13 |
| - type: string |
14 |
| - HTML_RENDER_API: |
15 |
| - required: true |
16 |
| - type: string |
17 |
| - secrets: |
18 |
| - READER_TOKEN: |
19 |
| - required: true |
20 |
| - NAIS_WORKLOAD_IDENTITY_PROVIDER: |
21 |
| - required: true |
| 3 | + workflow_call: |
| 4 | + inputs: |
| 5 | + naisEnv: |
| 6 | + required: true |
| 7 | + type: string |
| 8 | + VITE_APP_ORIGIN: |
| 9 | + required: true |
| 10 | + type: string |
| 11 | + XP_ORIGIN: |
| 12 | + required: true |
| 13 | + type: string |
| 14 | + HTML_RENDER_API: |
| 15 | + required: true |
| 16 | + type: string |
| 17 | + secrets: |
| 18 | + READER_TOKEN: |
| 19 | + required: true |
| 20 | + NAIS_WORKLOAD_IDENTITY_PROVIDER: |
| 21 | + required: true |
22 | 22 |
|
23 | 23 | jobs:
|
24 |
| - build-and-deploy: |
25 |
| - name: Build and deploy |
26 |
| - runs-on: ubuntu-latest |
27 |
| - environment: ${{ inputs.naisEnv }}-xp |
28 |
| - permissions: |
29 |
| - contents: "read" |
30 |
| - id-token: "write" |
31 |
| - steps: |
32 |
| - - name: Checkout repo |
33 |
| - uses: actions/checkout@v4 |
34 |
| - - name: Setup node.js |
35 |
| - uses: actions/setup-node@v4 |
36 |
| - with: |
37 |
| - node-version: '22' |
38 |
| - registry-url: 'https://npm.pkg.github.com' |
39 |
| - cache: 'npm' |
40 |
| - cache-dependency-path: '**/package-lock.json' |
41 |
| - - name: Install dependencies |
42 |
| - run: npm ci --include-workspace-root --workspace=common --workspace=xp-archive |
43 |
| - env: |
44 |
| - NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} |
45 |
| - - name: Set env vars |
46 |
| - working-directory: xp-archive |
47 |
| - run: | |
48 |
| - cat > .env <<EOF |
49 |
| - NODE_ENV=production |
50 |
| - APP_PORT=3499 |
51 |
| - APP_BASEPATH=/xp |
52 |
| - VITE_APP_ORIGIN=${{ inputs.VITE_APP_ORIGIN }} |
53 |
| - XP_ORIGIN=${{ inputs.XP_ORIGIN }} |
54 |
| - HTML_RENDER_API=${{ inputs.HTML_RENDER_API }} |
55 |
| - EOF |
56 |
| - - name: Build application |
57 |
| - run: npm run build |
58 |
| - working-directory: xp-archive |
59 |
| - - name: Build and push docker image |
60 |
| - uses: nais/docker-build-push@v0 |
61 |
| - id: docker-push |
62 |
| - with: |
63 |
| - team: personbruker |
64 |
| - project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} |
65 |
| - identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} |
66 |
| - dockerfile: Dockerfile_xp |
67 |
| - image_suffix: ${{ inputs.naisEnv }} |
68 |
| - - name: Deploy application |
69 |
| - uses: nais/deploy/actions/deploy@v2 |
70 |
| - env: |
71 |
| - CLUSTER: ${{ inputs.naisEnv }}-gcp |
72 |
| - RESOURCE: xp-archive/.nais/config.yml |
73 |
| - VAR: image=${{ steps.docker-push.outputs.image }} |
74 |
| - VARS: xp-archive/.nais/vars/${{ inputs.naisEnv }}.yml |
| 24 | + build-and-deploy: |
| 25 | + name: Build and deploy |
| 26 | + runs-on: ubuntu-latest |
| 27 | + environment: ${{ inputs.naisEnv }}-xp |
| 28 | + permissions: |
| 29 | + contents: read |
| 30 | + id-token: write |
| 31 | + steps: |
| 32 | + - name: Checkout repo |
| 33 | + uses: actions/checkout@v4 |
| 34 | + - name: Setup node.js |
| 35 | + uses: actions/setup-node@v4 |
| 36 | + with: |
| 37 | + node-version: 22 |
| 38 | + registry-url: 'https://npm.pkg.github.com' |
| 39 | + cache: 'npm' |
| 40 | + cache-dependency-path: '**/package-lock.json' |
| 41 | + - name: Install dependencies |
| 42 | + run: npm ci --include-workspace-root --workspace=common --workspace=xp-archive |
| 43 | + env: |
| 44 | + NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }} |
| 45 | + - name: Set env vars |
| 46 | + working-directory: xp-archive |
| 47 | + run: | |
| 48 | + cat > .env <<EOF |
| 49 | + NODE_ENV=production |
| 50 | + APP_PORT=3499 |
| 51 | + APP_BASEPATH=/xp |
| 52 | + VITE_APP_ORIGIN=${{ inputs.VITE_APP_ORIGIN }} |
| 53 | + XP_ORIGIN=${{ inputs.XP_ORIGIN }} |
| 54 | + HTML_RENDER_API=${{ inputs.HTML_RENDER_API }} |
| 55 | + EOF |
| 56 | + - name: Build application |
| 57 | + run: npm run build |
| 58 | + working-directory: xp-archive |
| 59 | + - name: Build and push docker image |
| 60 | + uses: nais/docker-build-push@v0 |
| 61 | + id: docker-push |
| 62 | + with: |
| 63 | + team: personbruker |
| 64 | + project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} |
| 65 | + identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} |
| 66 | + dockerfile: Dockerfile_xp |
| 67 | + image_suffix: ${{ inputs.naisEnv }} |
| 68 | + - name: Deploy application |
| 69 | + uses: nais/deploy/actions/deploy@v2 |
| 70 | + env: |
| 71 | + CLUSTER: ${{ inputs.naisEnv }}-gcp |
| 72 | + RESOURCE: xp-archive/.nais/config.yml |
| 73 | + VAR: image=${{ steps.docker-push.outputs.image }} |
| 74 | + VARS: xp-archive/.nais/vars/${{ inputs.naisEnv }}.yml |
0 commit comments