This repository has been archived by the owner on Mar 10, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (79 loc) · 2.72 KB
/
build-and-deploy.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
78
79
80
81
82
83
84
# This workflow trigger on push to any branch.
name: CI / CD
on:
push:
paths-ignore:
- '**.md'
- '.gitignore'
- 'LICENCE'
- 'CODEOWNERS'
- 'nais/alerterator.yml'
- '.github/workflows/apply-alerts.yml'
- '.github/workflows/snyk.yml'
branches:
env:
IMAGE: docker.pkg.github.com/${{ github.repository }}/omsorgspenger-api:${{ github.sha }}
GITHUB_USERNAME: x-access-token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
test:
name: Check Code
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: 11
distribution: 'zulu'
cache: 'gradle'
- name: Test Code
run: ./gradlew check
build-code-and-push-docker:
name: Build code and push docker image
if: startsWith(github.ref, 'refs/heads/dev-') || startsWith(github.ref, 'refs/heads/master') || github.event.deployment.payload.triggered # Build and push docker if branch is either master or dev-*
needs: test
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/[email protected]
- name: Set up JDK 11
uses: actions/[email protected]
with:
java-version: 11
distribution: 'zulu'
cache: 'gradle'
- name: Build JAR
run: ./gradlew shadowjar # Creates a combined JAR of project and runTime dependencies.
- name: Build and publish Docker image
run: |
docker build --tag ${IMAGE} .
docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} -p ${GITHUB_TOKEN}
docker push ${IMAGE}
deploy-dev-gcp:
name: Deploy to dev-gcp
if: startsWith(github.ref, 'refs/heads/dev-') || startsWith(github.ref, 'refs/heads/master') # Deploy if branch is either master or dev-*
needs: build-code-and-push-docker # Depends on build-code-and-push-docker job
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: nais/naiserator.yml
VARS: nais/dev-gcp.json
deploy-prod-gcp:
name: Deploy to prod-gcp
if: startsWith(github.ref, 'refs/heads/master') # If the branch is master
needs: build-code-and-push-docker # Depends on build-code-and-push-docker job
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-gcp
RESOURCE: nais/naiserator.yml
VARS: nais/prod-gcp.json