generated from navikt/tiltakspenger-template
-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (60 loc) · 2.21 KB
/
deploy-dev.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
name: Build, push and deploy to dev (manual)
on:
workflow_dispatch:
env:
IMAGE: ghcr.io/${{ github.repository }}:${{ github.sha }}
PRINT_PAYLOAD: true
jobs:
build:
name: Test, build and push
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: 21
- uses: gradle/gradle-build-action@v3
with:
arguments: build --info installDist
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Docker Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker build and push
uses: docker/build-push-action@v6
with:
context: .
tags: ${{ env.IMAGE }}
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Notify Slack in case of build failure
if: failure() && github.ref == 'refs/heads/main'
run: |
curl -X POST --data-urlencode "payload={ \"attachments\": [{ \"pretext\": \"[${{ github.event.repository.name }}] Build failed :cry:\", \"color\": \"danger\", \"fields\": [ { \"title\": \"Author\", \"value\": \"$AUTHOR\", \"short\": false }, { \"title\": \"Commit\", \"value\": \"<https://github.com/${{ github.repository }}/commit/$GITHUB_SHA|$GITHUB_SHA>\", \"short\": false } ] }] }" $WEBHOOK_URL
env:
BRANCH: ${{ github.ref }}
AUTHOR: ${{ github.event.pusher.name }}
WEBHOOK_URL: ${{ secrets.SLACK_INCOMING_WEBHOOK_URL }}
deploy-dev:
name: Deploy to NAIS dev
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: nais/deploy/actions/deploy@v2
env:
APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
CLUSTER: dev-gcp
RESOURCE: .nais/nais.yml,.nais/unleash-apitoken.yml
VAR: image=${{ env.IMAGE }},name=${{ github.event.repository.name }}
VARS: .nais/vars/dev.yml