-
Notifications
You must be signed in to change notification settings - Fork 8
82 lines (68 loc) · 2.64 KB
/
main.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
name: Build, push and deploy
on:
workflow_dispatch:
push:
env:
DEPLOYMENT_NAME: ${{ vars.TEAMNAME }}
DEPLOYMENT_TOKEN: ${{ secrets.TOKEN }}
NAMESPACE: ${{ vars.NAMESPACE }}
jobs:
build:
permissions:
packages: write
runs-on: ubuntu-latest
name: Build app
steps:
- name: Checkout the code
uses: actions/checkout@master
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: Cache maven packages
uses: actions/cache@v4
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2
- name: Prepare repository name
run: |
echo IMAGE_REPOSITORY=$(echo ${{ github.repository }} | tr '[:upper:]' '[:lower:]') >> $GITHUB_ENV
- name: Build jar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
run: |
mvn --batch-mode --update-snapshots clean spring-boot:build-image \
-Dspring-boot.build-image.imageName=ghcr.io/${{ env.IMAGE_REPOSITORY }}:latest
- name: Log in to registry
if: github.ref == 'refs/heads/main'
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push the Docker image to GHCR
if: github.ref == 'refs/heads/main'
run: |
docker push ghcr.io/${{ env.IMAGE_REPOSITORY }}
- name: Install Helm
if: github.ref == 'refs/heads/main'
uses: azure/setup-helm@v3
with:
version: 'latest' # default is latest (stable)
token: ${{ secrets.GITHUB_TOKEN }} # only needed if version is 'latest'
id: install
- name: Deploy Helm chart
if: github.ref == 'refs/heads/main'
run: |
echo "${{ env.DEPLOYMENT_TOKEN }}" > kubeconfig.yaml
helm upgrade --install \
${{ env.DEPLOYMENT_NAME }} \
charts/player \
--set "ingress.hosts[0].host=${{ env.DEPLOYMENT_NAME }}.play.continuouspoker.org" \
--set "ingress.hosts[0].paths[0].path=/" \
--set "ingress.tls[0].hosts[0]=${{ env.DEPLOYMENT_NAME }}.play.continuouspoker.org" \
--set "ingress.tls[0].secretName=letsencrypt-nginx-${{ env.DEPLOYMENT_NAME }}" \
--set "ingress.hosts[0].paths[0].pathType=ImplementationSpecific" \
--set "image.repository=ghcr.io/${{ env.IMAGE_REPOSITORY }}" \
--namespace ${{ env.NAMESPACE }} \
--kubeconfig kubeconfig.yaml \
--force
rm kubeconfig.yaml