Skip to content

Commit f074be3

Browse files
committed
Bytt til nyere workflow for å bygge docker image
1 parent 19701e5 commit f074be3

File tree

1 file changed

+28
-58
lines changed

1 file changed

+28
-58
lines changed

.github/workflows/deploy.yml

+28-58
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,13 @@ on:
44
workflow_dispatch:
55
push:
66

7-
env:
8-
IMAGE: ghcr.io/${{ github.repository }}/dp-faktasider-frontend:${{ github.sha }}
9-
LATEST_IMAGE: ghcr.io/${{ github.repository }}/dp-faktasider-frontend:latest
10-
117
jobs:
128
jest-test:
139
name: Jest tests
1410
runs-on: ubuntu-latest
1511
steps:
16-
- uses: actions/checkout@v3
17-
- uses: actions/setup-node@v3
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-node@v4
1814
with:
1915
node-version: 'lts/*'
2016
cache: "npm"
@@ -36,24 +32,14 @@ jobs:
3632
install:
3733
runs-on: ubuntu-latest
3834
steps:
39-
- uses: actions/checkout@v3
40-
41-
- name: Cache node_modules
42-
uses: actions/cache@v3
43-
id: node_modules
44-
with:
45-
path: ./node_modules
46-
key: modules-${{ hashFiles('package-lock.json') }}
47-
48-
- uses: actions/setup-node@v3
49-
if: steps.node_modules.outputs.cache-hit != 'true'
35+
- uses: actions/checkout@v4
36+
- uses: actions/setup-node@v4
5037
with:
5138
node-version: 'lts/*'
5239
cache: "npm"
5340
registry-url: "https://npm.pkg.github.com"
5441

5542
- run: npm ci --ignore-scripts
56-
if: steps.node_modules.outputs.cache-hit != 'true'
5743
env:
5844
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
5945

@@ -63,63 +49,47 @@ jobs:
6349
permissions:
6450
packages: write
6551
steps:
66-
- uses: actions/checkout@v3
67-
- uses: actions/setup-node@v3
52+
- uses: actions/checkout@v4
53+
- uses: actions/setup-node@v4
6854
with:
6955
node-version: "lts/*"
56+
cache: npm
7057

71-
- name: Cache node_modules
72-
uses: actions/cache@v3
73-
with:
74-
path: ./node_modules
75-
key: modules-${{ hashFiles('package-lock.json') }}
76-
77-
- name: Cache .next/cache
78-
uses: actions/cache@v3
79-
with:
80-
path: ./.next/cache
81-
# Generate a new cache whenever packages or source files change.
82-
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
83-
# If source files changed but packages didn't, rebuild from a prior cache.
84-
restore-keys: |
85-
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-
8658
- run: npm run build
8759

8860
# Bygg docker image
89-
- uses: docker/setup-buildx-action@v2
90-
- uses: docker/login-action@v1
61+
- name: docker-build-push
62+
uses: nais/docker-build-push@v0
63+
id: docker-build-push
9164
with:
92-
registry: ghcr.io
93-
username: ${{ github.repository_owner }}
94-
password: ${{ secrets.GITHUB_TOKEN }}
95-
96-
- uses: docker/build-push-action@v3
97-
with:
98-
context: .
99-
push: true
100-
pull: true
101-
tags: ${{ env.IMAGE }},${{ env.LATEST_IMAGE }}
102-
cache-from: type=gha
103-
cache-to: type=gha,mode=max
65+
team: teamdagpenger
66+
tag: ${{ github.sha }}
67+
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
68+
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
69+
salsa: false
10470

10571
- name: Cache static files
106-
uses: actions/cache@v3
72+
uses: actions/cache@v4
10773
with:
10874
path: ./.next/static
10975
key: ${{ github.sha }}
11076

77+
outputs:
78+
image: ${{ steps.docker-build-push.outputs.image }}
79+
digest: ${{ steps.docker-build-push.outputs.digest }}
80+
11181
deploy-dev-gcp:
11282
name: Deploy to dev gcp
113-
needs: [build, jest-test]
83+
needs: [ build, jest-test ]
11484
runs-on: ubuntu-latest
11585
steps:
116-
- uses: actions/checkout@v3
117-
- uses: nais/deploy/actions/deploy@v1
86+
- uses: actions/checkout@v4
87+
- uses: nais/deploy/actions/deploy@v2
11888
env:
119-
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
12089
CLUSTER: dev-gcp
12190
RESOURCE: nais/nais.yaml
12291
VARS: nais/dev-gcp/vars.yaml
92+
VAR: image=${{ needs.build.outputs.image }}
12393
PRINT_PAYLOAD: true
12494

12595
- name: Lag deployment i Sentry
@@ -137,17 +107,17 @@ jobs:
137107

138108
deploy-prod-gcp:
139109
name: Deploy to prod gcp
140-
needs: [deploy-dev-gcp]
110+
needs: [ build, deploy-dev-gcp ]
141111
if: github.ref == 'refs/heads/main'
142112
runs-on: ubuntu-latest
143113
steps:
144-
- uses: actions/checkout@v3
145-
- uses: nais/deploy/actions/deploy@v1
114+
- uses: actions/checkout@v4
115+
- uses: nais/deploy/actions/deploy@v2
146116
env:
147-
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
148117
CLUSTER: prod-gcp
149118
RESOURCE: nais/nais.yaml
150119
VARS: nais/prod-gcp/vars.yaml
120+
VAR: image=${{ needs.build.outputs.image }}
151121
PRINT_PAYLOAD: true
152122

153123
- name: Lag deployment i Sentry

0 commit comments

Comments
 (0)