-
Notifications
You must be signed in to change notification settings - Fork 2
85 lines (73 loc) · 2.64 KB
/
build-deploy.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
name: Build and Push Image to Registry
on:
workflow_dispatch:
push:
branches:
- main
permissions:
contents: write
packages: write
env:
registry: ghcr.io
image_name: ${{ github.repository }}
jobs:
build:
name: Docker build and push
runs-on: ubuntu-latest
outputs:
image_name: ${{ steps.set_outputs.outputs.image_name }}
new_tag: ${{ steps.set_outputs.outputs.new_tag }}
new_digest: ${{ steps.set_outputs.outputs.new_digest }}
steps:
- name: Checkout project sources
uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '21'
- name: Login to Github Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.registry }}
username: ${{ github.actor }}
password: ${{ github.token }}
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ github.token }}
- name: Build docker and push
id: build
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ env.registry }}/${{ github.repository }}:${{ steps.tag_version.outputs.new_tag }} , ${{ env.registry }}/${{ github.repository }}:latest
- name: Set outputs
id: set_outputs
run: |
echo 'image_name=${{ env.registry }}/${{ github.repository }}' >> $GITHUB_OUTPUT
echo 'new_digest=${{ steps.build.outputs.digest }}' >> $GITHUB_OUTPUT
echo 'new_tag=${{ steps.tag_version.outputs.new_tag }}' >> $GITHUB_OUTPUT
- name: Add summary of build
id: summary
run: |
echo '### Image release' >> $GITHUB_STEP_SUMMARY
echo '- Image name: ${{ env.registry }}/${{ github.repository }}' >> $GITHUB_STEP_SUMMARY
echo '- Digest: ${{ steps.build.outputs.digest }}' >> $GITHUB_STEP_SUMMARY
echo '- Tag: ${{ steps.tag_version.outputs.new_tag }}' >> $GITHUB_STEP_SUMMARY
deploy:
needs: [build]
name: Deploy to dev
uses: kartverket/bygning-apps/.github/workflows/update-app-version.yaml@main
with:
application_name: bygning-backend
image_name: ${{ needs.build.outputs.image_name }}
image_tag: ${{ needs.build.outputs.new_tag }}
image_digest: ${{ needs.build.outputs.new_digest }}
env: dev
namespace: matrikkelbygning-main
cluster: atgcp1
secrets:
DEPLOY_PAT: ${{ secrets.DEPLOY_PAT }}