-
Notifications
You must be signed in to change notification settings - Fork 2
105 lines (99 loc) · 3.12 KB
/
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Build, push, and deploy
on:
push:
paths-ignore:
- '.nais/alerts.yaml'
- '.github/workflows/alerts.yml'
- '.nais/aiven-topics.yaml'
- '.github/workflows/deploy-aiven-topics.yml'
- '*.md'
pull_request:
paths-ignore:
- '.nais/alerts.yaml'
- '.github/workflows/alerts.yml'
- '.nais/aiven-topics.yaml'
- '.github/workflows/deploy-aiven-topics.yml'
- '*.md'
env:
IMAGE: ghcr.io/${{ github.repository }}/altinnkanal-2:${{ github.sha }}
jobs:
test:
name: Run tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '11.x'
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('altinnkanal/build.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-cache-
- uses: actions/cache@v1
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-wrapper-
- name: Build and run tests
run: ./gradlew clean build
build:
name: Build and push Docker container
needs: test
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- uses: actions/checkout@v1
- uses: actions/setup-java@v1
with:
java-version: '11.x'
- uses: actions/cache@v1
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-cache-${{ hashFiles('altinnkanal/build.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-cache-
- uses: actions/cache@v1
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('gradle/wrapper/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-wrapper-
- name: Build JAR
run: ./gradlew clean build shadowJar -x test
- name: Build and publish Docker image
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
docker build . --pull --tag ${IMAGE}
echo "$GITHUB_TOKEN" | docker login ghcr.io --username "$GITHUB_REPOSITORY" --password-stdin
docker push ${IMAGE}
deploy-dev:
name: Deploy to NAIS dev
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-fss
RESOURCE: .nais/naiserator.yaml
VARS: .nais/config-dev.yaml
deploy-prod:
name: Deploy to NAIS prod
needs: deploy-dev
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: nais/deploy/actions/deploy@v1
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: prod-fss
RESOURCE: .nais/naiserator.yaml
VARS: .nais/config-prod.yaml