-
Notifications
You must be signed in to change notification settings - Fork 1
132 lines (131 loc) · 3.86 KB
/
build-image.yml
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
121
122
123
124
125
126
127
128
129
130
131
132
name: Build docker image
on:
workflow_call:
inputs:
environment:
required: true
type: string
imagename:
required: true
type: string
ENV:
required: true
type: string
ADMIN_ORIGIN:
required: true
type: string
APP_ORIGIN:
required: true
type: string
REVALIDATOR_PROXY_ORIGIN:
required: true
type: string
DECORATOR_URL:
required: true
type: string
XP_ORIGIN:
required: true
type: string
TELEMETRY_URL:
required: true
type: string
INNLOGGINGSSTATUS_URL:
required: true
type: string
NAVNO_API_URL:
required: true
type: string
FAILOVER_ORIGIN:
required: true
type: string
RELEASE_TAG:
required: false
type: string
IS_FAILOVER_INSTANCE:
required: false
type: boolean
NODE_ENV:
required: true
type: string
secrets:
READER_TOKEN:
required: true
SERVICE_SECRET:
required: false
NAIS_WORKLOAD_IDENTITY_PROVIDER:
required: true
outputs:
image:
description: "Url to docker image"
value: ${{ jobs.build_image.outputs.image }}
jobs:
build_image:
name: Build docker image
runs-on: ubuntu-latest
permissions:
contents: "read"
id-token: "write"
environment: ${{ inputs.environment }}
outputs:
image: ${{ steps.docker-push.outputs.image }}
steps:
- name: Checkout repo
uses: actions/checkout@v4
- name: Setup node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://npm.pkg.github.com'
cache: 'npm'
- name: Set app environmment
run: |
cat > .env <<EOF
ENV=${{ inputs.ENV }}
NODE_ENV=${{ inputs.NODE_ENV }}
ADMIN_ORIGIN=${{ inputs.ADMIN_ORIGIN }}
APP_ORIGIN=${{ inputs.APP_ORIGIN }}
DECORATOR_URL=${{ inputs.DECORATOR_URL }}
XP_ORIGIN=${{ inputs.XP_ORIGIN }}
TELEMETRY_URL=${{ inputs.TELEMETRY_URL }}
REVALIDATOR_PROXY_ORIGIN=${{ inputs.REVALIDATOR_PROXY_ORIGIN }}
FAILOVER_ORIGIN=${{ inputs.FAILOVER_ORIGIN }}
IS_FAILOVER_INSTANCE=${{ inputs.IS_FAILOVER_INSTANCE }}
INNLOGGINGSSTATUS_URL=${{ inputs.INNLOGGINGSSTATUS_URL }}
NAVNO_API_URL=${{ inputs.NAVNO_API_URL }}
ASSET_PREFIX=https://cdn.nav.no/personbruker/nav-enonicxp-frontend
IMAGE_CACHE_DIR=/tmp/images
NEXT_TELEMETRY_DISABLED=1
EOF
- name: Nextjs cache
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.next/cache
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}
- name: Install dependencies
run: npm ci
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
- name: Run linting
run: npm run lint
- name: Run tests
run: npm run test
- name: Build application
run: npm run build
env:
SERVICE_SECRET: ${{ secrets.SERVICE_SECRET }}
- name: Upload static files to NAV CDN
uses: navikt/frontend/actions/cdn-upload/v2
with:
team: personbruker
source: ./.next/static
destination: nav-enonicxp-frontend/_next
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
- name: Build and push docker image
uses: nais/docker-build-push@v0
id: docker-push
with:
team: personbruker
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
image_suffix: ${{ inputs.imagename }}