Skip to content

Commit 0630a58

Browse files
committed
Deploy på samme måte som andre FE brilleapps
1 parent e26578c commit 0630a58

File tree

2 files changed

+93
-60
lines changed

2 files changed

+93
-60
lines changed

.github/workflows/deploy-dev.yml

Lines changed: 64 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,99 @@
1-
name: Build, deploy to dev-gcp
1+
name: Bygg, deploy til dev-gcp og lag release
22
on:
33
push:
44
paths-ignore:
55
- '**.md'
66
- '.gitignore'
77
- 'LICENCE'
88
- 'CODEOWNERS'
9-
- 'docs/**'
10-
- 'docs'
11-
- 'docs/'
12-
- '/docs'
139
branches:
14-
- main_
15-
16-
env:
17-
IMAGE: 'ghcr.io/navikt/hm-brilleavtale-frontend:${{ github.sha }}'
10+
- main
1811

1912
jobs:
20-
2113
build:
14+
name: Bygg
2215
runs-on: ubuntu-latest
2316
permissions:
2417
contents: "write"
2518
id-token: "write"
2619
packages: "write"
2720
timeout-minutes: 15
21+
outputs:
22+
docker_image: ${{ steps.docker-build-push.outputs.image }}
23+
version_tag: ${{ steps.version-tag.outputs.VERSION_TAG}}
24+
2825
steps:
2926
- name: Checkout code
30-
uses: actions/checkout@v3
27+
uses: actions/checkout@v4
28+
3129
- name: pre-deploy
32-
uses: navikt/digihot-deploy/actions/pre-deploy@v2
30+
uses: navikt/digihot-deploy/actions/pre-deploy@v3
3331
env:
3432
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
35-
DOCKER_IMAGE: ghcr.io/navikt/hm-brilleavtale-frontend
36-
- name: Set up Docker Buildx
37-
uses: docker/setup-buildx-action@v2
3833

39-
- name: Login to GitHub Package Repository
40-
uses: docker/login-action@v2
34+
- name: Bygg og push Docker image
35+
uses: nais/docker-build-push@v0
36+
id: docker-build-push
4137
with:
42-
registry: ghcr.io
43-
username: ${{ github.repository_owner }}
44-
password: ${{ secrets.GITHUB_TOKEN }}
38+
team: teamdigihot
39+
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
40+
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
41+
tag: ${{ env.VERSION_TAG }}
42+
build_secrets: NODE_AUTH_TOKEN=${{ secrets.READER_TOKEN }}
4543

46-
- name: Set up .npmrc to use in Docker build
47-
uses: actions/setup-node@v3
48-
with:
49-
registry-url: "https://npm.pkg.github.com"
44+
- name: Definer release tag
45+
id: version-tag
46+
run: echo "VERSION_TAG=${{env.VERSION_TAG}}" >> "$GITHUB_OUTPUT"
47+
48+
deploy-labs:
49+
name: Deploy til labs-gcp
50+
runs-on: ubuntu-latest
51+
needs: [build]
52+
permissions:
53+
contents: write
54+
id-token: write
55+
timeout-minutes: 15
5056

51-
- run: cp $NPM_CONFIG_USERCONFIG .npmrc
57+
steps:
58+
- name: Sjekk ut koden
59+
uses: actions/checkout@v4
5260

53-
- name: Build and push
54-
uses: docker/build-push-action@v4
55-
with:
56-
context: .
57-
tags: ${{ env.IMAGE }}
58-
push: true
59-
cache-from: type=gha
60-
cache-to: type=gha,mode=max
61-
secrets: |
62-
"NODE_AUTH_TOKEN=${{ secrets.READER_TOKEN }}"
63-
- name: deploy to dev
64-
uses: nais/deploy/actions/deploy@v1
61+
- name: Deploy
62+
uses: nais/deploy/actions/deploy@v2
63+
env:
64+
CLUSTER: dev-gcp
65+
RESOURCE: .nais/labs.yml
66+
IMAGE: ${{ needs.build.outputs.docker_image }}
67+
68+
deploy-dev:
69+
name: Deploy til dev-gcp
70+
runs-on: ubuntu-latest
71+
needs: [ build ]
72+
permissions:
73+
contents: write
74+
id-token: write
75+
timeout-minutes: 15
76+
env:
77+
VERSION_TAG: ${{ needs.build.outputs.version_tag }}
78+
79+
steps:
80+
- name: Sjekk ut koden
81+
uses: actions/checkout@v4
82+
83+
- name: Deploy
84+
uses: nais/deploy/actions/deploy@v2
6585
env:
66-
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
6786
CLUSTER: dev-gcp
6887
RESOURCE: .nais/dev.yml
69-
VAR: image=${{ env.IMAGE }},commit=${{ github.sha }}
70-
- name: post-deploy
88+
IMAGE: ${{ needs.build.outputs.docker_image }}
89+
90+
- name: Etter deploy
7191
if: github.ref == 'refs/heads/main'
72-
uses: navikt/digihot-deploy/actions/post-deploy@v2
92+
uses: navikt/digihot-deploy/actions/post-deploy@v3
7393
env:
7494
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75-
- name: draft release
95+
96+
- name: Lag release
7697
if: github.ref == 'refs/heads/main'
7798
uses: actions/create-release@latest
7899
env:
@@ -82,12 +103,4 @@ jobs:
82103
release_name: ${{ env.APPLICATION }} ${{ env.VERSION_TAG }}
83104
body: ${{ env.CHANGE_LOG }}
84105
draft: true
85-
prerelease: false
86-
- name: deploy to labs
87-
uses: nais/deploy/actions/deploy@v1
88-
env:
89-
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
90-
CLUSTER: dev-gcp
91-
RESOURCE: .nais/labs.yml
92-
VAR: image=${{ env.IMAGE }},commit=${{ github.sha }}
93-
106+
prerelease: false

.github/workflows/deploy-prod.yml

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,47 @@
1-
name: deploy-prod
1+
name: Deploy til prod-gcp
2+
23
on:
34
release:
4-
types: [published]
5+
types:
6+
- published
57

68
jobs:
79
deploy-prod:
810
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
id-token: write
14+
915
steps:
10-
- uses: actions/checkout@v1
11-
- name: get release tag
16+
- name: Sjekk ut koden
17+
uses: actions/checkout@v4
18+
19+
- name: NAIS-login
20+
uses: nais/login@v0
21+
id: nais-login
22+
with:
23+
team: teamdigihot
24+
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
25+
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
26+
27+
- name: Definer release tag
1228
env:
1329
VERSION_TAG: ${{ github.event.release.tag_name }}
30+
REGISTRY: ${{ steps.nais-login.outputs.registry }}
31+
APP: ${{ github.event.repository.name }}
1432
run: |
15-
IMAGE=ghcr.io/$GITHUB_REPOSITORY:$VERSION_TAG
33+
IMAGE=$REGISTRY/$APP:$VERSION_TAG
1634
echo "IMAGE=${IMAGE}" >> $GITHUB_ENV
1735
echo $IMAGE
18-
- uses: nais/deploy/actions/deploy@v1
19-
name: deploy to prod-gcp
36+
37+
- name: Deploy til prod-gcp
38+
uses: nais/deploy/actions/deploy@v2
2039
env:
21-
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
2240
CLUSTER: prod-gcp
2341
RESOURCE: .nais/prod.yml
24-
- name: post-production
42+
VAR: commit=${{ github.sha }}
43+
44+
- name: Etter deploy
2545
uses: navikt/digihot-deploy/actions/post-production@v2
2646
env:
2747
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)