-
Notifications
You must be signed in to change notification settings - Fork 2
77 lines (73 loc) · 2.16 KB
/
api-release.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
name: release farskapsportal-api
on:
push:
branches:
- release
paths:
- 'pom.xml'
- '.m2/**'
- '.github/workflows/**'
- 'apps/api/**'
- 'libs/**'
- '.nais/app/**'
- '**/api-ci.yml'
env:
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
verify:
name: Verify that release commit is present in main branch
runs-on: ubuntu-latest
steps:
- run: git clone --bare https://$GITHUB_ACTOR:[email protected]/${{ github.repository }}
- name: check if commit to build exists in main branch
run: |
cd $( echo ${{ github.repository }} | sed 's;navikt/;;' ).git
git log | grep -c ${{ github.sha }}
build:
name: Build release with maven and docker
runs-on: ubuntu-latest
needs: verify
permissions:
contents: "read"
id-token: "write"
outputs:
image: ${{ steps.docker-push.outputs.image }}
tag: ${{ steps.docker-push.outputs.tag }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
java-version: 21
distribution: 'temurin'
cache: 'maven'
- uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- run: mvn -B -e --no-transfer-progress package --settings .m2/maven-settings.xml --file pom.xml
- uses: nais/docker-build-push@v0
id: docker-push
with:
team: farskapsportal
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
deploy:
runs-on: ubuntu-latest
name: Deploy docker image to prod
needs: build
permissions:
contents: "read"
id-token: "write"
steps:
- uses: actions/checkout@v4
with:
path: deploy
- uses: nais/deploy/actions/deploy@v2
env:
CLUSTER: prod-gcp
RESOURCE: deploy/.nais/app/naiserator-prod.yml
VARS: deploy/.nais/app/prod.yml
IMAGE: ${{ needs.build.outputs.image }}