This repository has been archived by the owner on Mar 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
84 lines (76 loc) · 2.45 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
name: Build & deploy
on: [push]
env:
IMAGE: docker.pkg.github.com/${{ github.repository }}/altinn-meldinger-api:${{ github.sha }}
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '16'
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Run tests
run: mvn test
build:
name: Build
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '16'
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Build jar with Maven
run: mvn package -DskipTests
- name: Build and publish Docker image
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker build --tag ${IMAGE} .
echo ${GITHUB_TOKEN} | docker login docker.pkg.github.com -u ${GITHUB_REPOSITORY} --password-stdin
echo ${IMAGE}
docker push ${IMAGE}
deploy-to-dev:
name: Deploy to dev
needs: build
#########################
### DEVELOPERS: Insert your feature branch name below (in addition to main) if you want to deploy it to dev
### e.g. github.ref == 'refs/heads/main' || github.ref == 'refs/heads/test-branch'
#########################
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/ny-namespace'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_KEY_PERMITTERING_OG_NEDBEMANNING }}
CLUSTER: dev-gcp
VAR: version=${{ env.IMAGE }}
RESOURCE: nais/dev-gcp.yaml
deploy-to-prod:
name: Deploy to prod
needs: build
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_KEY_PERMITTERING_OG_NEDBEMANNING }}
CLUSTER: prod-gcp
VAR: version=${{ env.IMAGE }}
RESOURCE: nais/prod-gcp.yaml