generated from loft-demos/vcluster-platform-demo-app-template
-
Notifications
You must be signed in to change notification settings - Fork 0
116 lines (110 loc) · 3.78 KB
/
main-build-push.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: build-push-main
# on merge to main from pull request (recommended)
on:
push:
branches:
- main
paths:
- 'src/**'
- 'helm-chart/**'
concurrency: production
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
changes:
runs-on: ubuntu-22.04
outputs:
src: ${{ steps.changes.outputs.src }}
helm-chart: ${{ steps.changes.outputs.helm-chart }}
steps:
- uses: actions/checkout@v3
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
src:
- 'src/**'
helm-chart:
- 'helm-chart/**'
app-update:
needs: changes
if: ${{ needs.changes.outputs.src == 'true' }}
runs-on: ubuntu-22.04
permissions:
packages: write
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install PyBump
run: |
python3 -m pip install pybump
- name: update-chart-app-version
id: update-chart-app-version
run: |
pybump bump --file helm-chart/Chart.yaml --level patch --app-version
NEW_APP_VERSION=$(yq .appVersion helm-chart/Chart.yaml)
echo $NEW_APP_VERSION
echo "NEW_APP_VERSION=$(echo $NEW_APP_VERSION)" >> "$GITHUB_ENV"
yq e -i ".deployment.commit = \"${{ github.sha }}\"" helm-chart/values.yaml
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git commit -a -m "updating helm chart app version to $NEW_APP_VERSION"
git push
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
registry: ghcr.io
- name: Push new app version
id: push-app-version
uses: docker/build-push-action@v4
with:
context: ./src
platforms: linux/amd64,linux/arm64
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:buildcache,mode=max
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.NEW_APP_VERSION }}
outputs: type=image,name=target,annotation-index.org.opencontainers.image.description=Simple echo app based on the HashiCorp echo-http.
- name: Delete Old Images
uses: actions/delete-package-versions@v4
with:
package-name: ${{ github.event.repository.name }}
package-type: 'container'
min-versions-to-keep: 9
helm-chart-update:
needs: changes
if: ${{ needs.changes.outputs.helm-chart == 'true' }}
runs-on: ubuntu-22.04
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v3
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Install PyBump
run: |
python3 -m pip install pybump
- name: update-chart-app-version
id: update-chart-version
run: |
pybump bump --file helm-chart/Chart.yaml --level minor
NEW_VERSION=$(yq .version helm-chart/Chart.yaml)
echo $NEW_VERSION
echo "NEW_VERSION=$(echo $NEW_VERSION)" >> "$GITHUB_ENV"
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git commit -a -m "updating helm chart version to $NEW_VERSION"
git push