@@ -12,81 +12,45 @@ permissions:
12
12
packages : write
13
13
14
14
jobs :
15
- setup :
15
+ build :
16
+ name : Build and push docker image
16
17
runs-on : ubuntu-latest
18
+ permissions :
19
+ contents : write
20
+ id-token : write
17
21
outputs :
18
- docker_image : ${{ env.IMAGE_FULL_NAME }}
19
- should_build_image : ${{ env.SHOULD_BUILD_IMAGE }}
22
+ image : ${{ steps.docker-build-push.outputs.image }}
20
23
steps :
24
+ - uses : actions/checkout@v4
21
25
22
- - name : ' Sjekk ut ønsket commit'
23
- uses : ' actions/checkout@v3'
24
-
25
- - name : ' Utled navn på docker-image basert på siste commit'
26
- run : |
27
- APP_NAME=$(echo $GITHUB_REPOSITORY | rev | cut -f1 -d"/" | rev )
28
- TAG_NAME="$(git log -1 --pretty='%ad' --date=format:'%Y%m%d%H%M%S')-$(git log -1 --pretty='%h')"
29
- IMAGE_BASE="ghcr.io/$GITHUB_REPOSITORY/$APP_NAME"
30
- echo "IMAGE_FULL_NAME=$IMAGE_BASE:$TAG_NAME" >> $GITHUB_ENV
31
- echo "IMAGE_TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
32
-
33
- - name : ' Sjekker om docker-image eksisterer fra før av'
34
- run : |
35
- echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_REPOSITORY --password-stdin
36
- RESULT=$(docker manifest inspect ${{ env.IMAGE_FULL_NAME }} > /dev/null 2> /dev/null ; echo $?)
37
- echo "SHOULD_BUILD_IMAGE=$([[ $RESULT == 0 ]] && echo 'false' || echo 'true' )" >> $GITHUB_ENV
38
-
39
- build-docker-image :
40
- needs : setup
41
- if : needs.setup.outputs.should_build_image == 'true'
42
- runs-on : ubuntu-latest
43
- steps :
44
- - uses : actions/checkout@v3
45
-
46
- - name : ' Setup java'
47
- uses : actions/setup-java@v1
26
+ - uses : actions/setup-java@v3
48
27
with :
49
- java-version : ' 17.x'
50
-
51
- - name : ' Finn cache-variabler'
52
- uses : navikt/pb-common-gh-actions/cache-prep@v2
28
+ java-version : 17
29
+ distribution : ' temurin'
53
30
54
- - name : ' Sett opp cache'
55
- uses : actions/cache@v2
56
- with :
57
- path : |
58
- ${{ env.CACHE_PATHS }}
59
- key : ${{ runner.os }}${{ env.CACHE_KEY_NAMESPACE }}${{ hashFiles(env.CACHE_KEY_HASHED_PATH) }}
31
+ - name : Gradle build
32
+ run : ./gradlew assemble
60
33
61
- - name : ' Bygg prosjekt'
62
- uses : navikt/pb-common-gh-actions/build@v2
34
+ - name : Build and push image to GAR
35
+ uses : nais/docker-build-push@v0
36
+ id : docker-build-push
63
37
with :
64
- SKIP_TESTS : " true"
65
- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
66
-
67
- - name : ' Bygg, tag og push Docker image'
68
- run : |
69
- echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_REPOSITORY --password-stdin
70
- docker build --tag ${{ needs.setup.outputs.docker_image }} .
71
- docker push ${{ needs.setup.outputs.docker_image }}
38
+ team : min-side
39
+ identity_provider : ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
40
+ project_id : ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
72
41
73
42
deploy :
74
- needs :
75
- - setup
76
- - build-docker-image
43
+ name : Deploy to NAIS
44
+ needs : build
77
45
runs-on : ubuntu-latest
78
- if : |
79
- always() &&
80
- ( needs.build-docker-image.result == 'success' || needs.build-docker-image.result == 'skipped' )
46
+ permissions :
47
+ contents : read
48
+ id-token : write
81
49
steps :
82
- - uses : actions/checkout@v3
50
+ - uses : actions/checkout@v4
83
51
84
- - name : ' Deployer ${{ github.ref_name }} til ${{ inputs.cluster }}'
85
- uses : ' nais/deploy/actions/deploy@v1'
52
+ - uses : nais/deploy/actions/deploy@v2
86
53
env :
87
- APIKEY : ${{ secrets.NAIS_DEPLOY_APIKEY }}
88
54
CLUSTER : ${{ inputs.cluster }}
89
55
RESOURCE : ./nais/${{ inputs.cluster }}/nais.yaml
90
- VAR : version=${{ needs.setup.outputs.docker_image }}
91
- PRINT_PAYLOAD : true
92
- REF : ${{ github.sha }}
56
+ VAR : version=${{ needs.build.outputs.image }}
0 commit comments