-
Notifications
You must be signed in to change notification settings - Fork 3
59 lines (51 loc) · 1.63 KB
/
build-and-publish.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
name: Build and Publish
on:
push:
branches: [ master ]
paths:
- 'src/**'
- 'pom.xml'
- 'build.gradle'
jobs:
build-and-push-docker-image:
name: Build Docker image and push to repositories
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github Packages
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
- name: Build image and push to GitHub Container Registry
uses: docker/build-push-action@v6
id: docker_build
with:
context: .
tags: |
ghcr.io/damingerdai/hoteler:${{ github.sha }}
push: ${{ github.ref == 'refs/heads/master' }}
platforms: linux/amd64,linux/arm64
provenance: true
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
deploy-to-kubernetes:
needs: build-and-push-docker-image
name: Deploy to kubernetes
runs-on: ubuntu-latest
steps:
- name: Authenticate to k3s
uses: Azure/k8s-set-context@v4
with:
kubeconfig: ${{ secrets.KUBE_CONFIG }}
- name: Deploy to k3s
run: |-
kubectl set image deployment/hoteler-api hoteler-api=ghcr.io/damingerdai/hoteler:${{ github.sha }} -n hoteler-namespace
kubectl rollout status deployment/hoteler-api -n hoteler-namespace