This repository has been archived by the owner on Jul 22, 2024. It is now read-only.
generated from navikt/tiltakspenger-template
-
Notifications
You must be signed in to change notification settings - Fork 0
88 lines (77 loc) · 2.79 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
name: Build, push, and deploy
on: push
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
if: github.ref == 'refs/heads/main'
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Docker Registry
if: github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker build and push
if: github.ref == 'refs/heads/main'
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
if: github.ref == 'refs/heads/main'
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
VAR: image=${{ env.IMAGE }},name=${{ github.event.repository.name }}
VARS: .nais/vars/dev.yml
# deploy-prod:
# name: Deploy to NAIS prod
# needs: deploy-dev
# if: github.ref == 'refs/heads/main'
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: nais/deploy/actions/deploy@v2
# env:
# APIKEY: ${{ secrets.NAIS_DEPLOY_APIKEY }}
# CLUSTER: prod-gcp
# RESOURCE: .nais/nais.yml
# VAR: image=${{ env.IMAGE }},name=${{ github.event.repository.name }}
# VARS: .nais/vars/prod.yml