-
Notifications
You must be signed in to change notification settings - Fork 4
132 lines (120 loc) · 4.09 KB
/
deploy-to-dev.yaml
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Manual deploy to dev
on:
workflow_call:
inputs:
e2e_tag:
description: "Tag of E2E image to run"
required: false
default: latest
type: string
secrets:
NAIS_DEPLOY_API_KEY:
description: "API key for nais/deploy"
required: true
NAIS_WORKLOAD_IDENTITY_PROVIDER:
description: "Identity provider for nais/docker-build-push"
required: true
workflow_dispatch:
inputs:
e2e_tag:
description: "Tag of E2E image to run"
required: false
default: latest
type: string
run-name: Dev deploy of ${{ github.ref_name }}
jobs:
build:
name: Build
permissions:
contents: read
id-token: write
outputs:
image: ${{ steps.docker-build-push.outputs.image }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cache
uses: actions/cache@v3
with:
path: ~/.gradle/caches
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle.kts') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Install Java 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: temurin
- name: Test and build
run: ./gradlew test bootJar
env:
ORG_GRADLE_PROJECT_githubUser: x-access-token
ORG_GRADLE_PROJECT_githubPassword: ${{ secrets.GITHUB_TOKEN }}
- name: Build & push Docker image
uses: nais/docker-build-push@v0
id: docker-build-push
with:
team: klage # required
tag: ${{ github.sha }} # optional
push_image: true # optional, default true
dockerfile: Dockerfile # optional, default Dockerfile
docker_context: . # optional, default .
image_suffix: # optional, default empty
cache_from: type=gha # optional, default type=gha
cache_to: type=gha,mode=max # optional, default type=gha,mode=max
identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }} # required, but is defined as an organization secret
project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }} # required, but is defined as an organization variable
build_args: |
VERSION=${CI}
- name: Post failures to Slack
if: failure()
run: |
curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":ghost:\"}" $WEBHOOK_URL
env:
MESSAGE: "Bygg feilet"
CHANNEL: "#klage-notifications"
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
deploy_to_dev:
name: Deploy
needs: build
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
name: Checkout code
- name: Deploy to dev
uses: nais/deploy/actions/deploy@v1
env:
TEAM: klage
CLUSTER: dev-gcp
VARS: deploy/dev.yaml
RESOURCE: deploy/nais.yaml
APIKEY: ${{ secrets.NAIS_DEPLOY_API_KEY }}
VAR: image=${{ needs.build.outputs.image }}
IMAGE: ${{ needs.build.outputs.image }}
- name: Post failures to Slack
if: failure()
run: |
curl -X POST --data-urlencode "payload={\"channel\": \"$CHANNEL\", \"text\": \"$MESSAGE\", \"icon_emoji\": \":ghost:\"}" $WEBHOOK_URL
env:
MESSAGE: "Deploy til dev feilet"
CHANNEL: "#klage-notifications"
WEBHOOK_URL: ${{ secrets.WEBHOOK_URL }}
e2e_test:
name: E2E
needs: deploy_to_dev
permissions:
contents: read
id-token: write
runs-on: ubuntu-latest
steps:
- name: E2E
uses: navikt/kabal-e2e-tests/.github/actions/run@main
with:
e2e_tag: ${{ inputs.e2e_tag }}
nais_deploy_api_key: ${{ secrets.NAIS_DEPLOY_API_KEY }}
nais_management_project_id: ${{ vars.NAIS_MANAGEMENT_PROJECT_ID }}
nais_workload_identity_provider: ${{ secrets.NAIS_WORKLOAD_IDENTITY_PROVIDER }}