Skip to content

Commit cc7010c

Browse files
authored
feat. Sette opp ny workflow med nais/docker-build-push@v0 og bygg av branch (#1205)
1 parent 102c6fc commit cc7010c

File tree

5 files changed

+223
-187
lines changed

5 files changed

+223
-187
lines changed

.editorconfig

+6
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,9 @@ indent_size = 4
55
indent_style = space
66
insert_final_newline = true
77
max_line_length = 120
8+
9+
[*.yml]
10+
indent_size = 2
11+
12+
[*.yaml]
13+
indent_size = 2

.github/workflows/bygg-branch.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Bygg branch
2+
3+
on:
4+
push:
5+
branches:
6+
- '**'
7+
- '!master'
8+
9+
jobs:
10+
build:
11+
name: Bygg branch
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Sjekk ut kode
15+
uses: actions/checkout@v4
16+
- name: Setup node.js
17+
uses: actions/setup-node@v3
18+
with:
19+
registry-url: 'https://npm.pkg.github.com'
20+
- name: Install
21+
run: npm ci
22+
env:
23+
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
24+
- name: Server install
25+
working-directory: ./server
26+
run: npm ci
27+
env:
28+
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
29+
- name: Typescript
30+
run: npm run ts
31+
- name: Prettier
32+
run: npm run prettier
33+
- name: Kjør tester
34+
run: npm run test
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,19 @@
1-
name: Bygg og deploy dev
1+
name: Bygg og deploy branch
22

3-
on:
4-
workflow_dispatch:
5-
6-
env:
7-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8-
GITHUB_REPOSITORY: ${{ github.repository }}
9-
IMAGE: ghcr.io/${{ github.repository }}/tiltaksgjennomforing:${{ github.sha }}
10-
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
3+
on: workflow_dispatch
114

125
jobs:
13-
bygg:
6+
build:
7+
name: Bygg
148
permissions:
15-
packages: write
16-
name: Bygg og deploy
17-
runs-on: ubuntu-20.04
9+
contents: read
10+
id-token: write
11+
outputs:
12+
image: ${{ steps.docker-build-push.outputs.image }}
13+
runs-on: ubuntu-latest
1814
steps:
1915
- name: Sjekk ut kode
20-
uses: actions/checkout@v3
16+
uses: actions/checkout@v4
2117
- name: Setup node.js
2218
uses: actions/setup-node@v3
2319
with:
@@ -47,56 +43,64 @@ jobs:
4743
- name: Remove source maps
4844
run: |
4945
rm dist/client/assets/*.map
50-
- name: Bygg, tag og push Docker-image
51-
run: |
52-
echo ${GITHUB_TOKEN} | docker login ghcr.io -u ${GITHUB_REPOSITORY} --password-stdin
53-
docker build --tag ${IMAGE} .
54-
docker push ${IMAGE}
46+
- name: Push docker image to GAR
47+
uses: nais/docker-build-push@v0
48+
id: docker-build-push
49+
with:
50+
team: arbeidsgiver
51+
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
52+
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
5553

5654
deploy-dev-gcp-intern:
5755
name: Deploy til dev-gcp intern
58-
runs-on: ubuntu-20.04
59-
needs: bygg
56+
runs-on: ubuntu-latest
57+
needs: build
58+
permissions:
59+
contents: read
60+
id-token: write
6061
steps:
6162
- name: Sjekk ut kode
62-
uses: actions/checkout@v3
63+
uses: actions/checkout@v4
6364
- name: Deploy til dev-gcp intern
64-
uses: nais/deploy/actions/deploy@v1
65+
uses: nais/deploy/actions/deploy@v2
6566
env:
66-
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
6767
CLUSTER: dev-gcp
6868
RESOURCE: nais/nais-gcp-intern.yaml
69-
PRINT_PAYLOAD: true
7069
VARS: nais/dev-gcp-intern.yaml
71-
70+
VAR: image=${{ needs.build.outputs.image }}
71+
7272
deploy-dev-gcp-ekstern:
7373
name: Deploy til dev-gcp ekstern
74-
runs-on: ubuntu-20.04
75-
needs: bygg
74+
runs-on: ubuntu-latest
75+
needs: build
76+
permissions:
77+
contents: read
78+
id-token: write
7679
steps:
7780
- name: Sjekk ut kode
78-
uses: actions/checkout@v3
81+
uses: actions/checkout@v4
7982
- name: Deploy til dev-gcp ekstern
80-
uses: nais/deploy/actions/deploy@v1
83+
uses: nais/deploy/actions/deploy@v2
8184
env:
82-
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
8385
CLUSTER: dev-gcp
8486
RESOURCE: nais/nais-gcp-ekstern.yaml
85-
PRINT_PAYLOAD: true
8687
VARS: nais/dev-gcp-ekstern.yaml
87-
88+
VAR: image=${{ needs.build.outputs.image }}
89+
8890
deploy-dev-gcp-labs:
8991
name: Deploy til dev-gcp (labs)
90-
runs-on: ubuntu-20.04
91-
needs: bygg
92+
runs-on: ubuntu-latest
93+
needs: build
94+
permissions:
95+
contents: read
96+
id-token: write
9297
steps:
9398
- name: Sjekk ut kode
94-
uses: actions/checkout@v3
99+
uses: actions/checkout@v4
95100
- name: Deploy til dev-gcp
96-
uses: nais/deploy/actions/deploy@v1
101+
uses: nais/deploy/actions/deploy@v2
97102
env:
98-
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
99103
CLUSTER: dev-gcp
100104
RESOURCE: nais/dev-gcp-labs.yaml
101-
PRINT_PAYLOAD: true
102105
VARS: nais/dev-gcp-labs.json
106+
VAR: image=${{ needs.build.outputs.image }}

0 commit comments

Comments
 (0)