-
Notifications
You must be signed in to change notification settings - Fork 161
98 lines (91 loc) · 3.68 KB
/
helm.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
name: Helm chart
on:
push:
branches:
- 'main'
paths:
- 'charts/**'
pull_request:
branches:
- 'main'
paths:
- 'charts/**'
workflow_dispatch:
permissions:
contents: read # for actions/checkout to fetch code
jobs:
helm-new-version:
runs-on: ubuntu-latest
outputs:
old-version: ${{ steps.old-version.outputs.version }}
new-version: ${{ steps.new-version.outputs.version }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Find new version
id: new-version
run: |
NEW_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml)
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Find old version
id: old-version
run: |
git checkout ${{ github.event.pull_request.base.sha || github.event.before }}
OLD_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml)
echo "version=$OLD_VERSION" >> $GITHUB_OUTPUT
helm-will-release:
runs-on: ubuntu-latest
needs: helm-new-version
if: github.event_name == 'pull_request' && needs.helm-new-version.outputs.old-version != needs.helm-new-version.outputs.new-version
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
fetch-depth: 0
- name: Find out if there's more changes to release
id: extra
run: |
last_revision=$(git blame ${{ github.event.pull_request.base.sha }} -L '/^version: [0-9.]\+$/,+1' charts/gitops-server/Chart.yaml | awk '{print $1}')
set +e
git log --exit-code $last_revision...${{ github.event.pull_request.base.sha }} charts/gitops-server
unreleased_commits=$?
if [[ $unreleased_commits == 1 ]]; then
echo "unreleased-commits=The last chart was last released in $last_revision and there have been other changes in the chart since" >> $GITHUB_OUTPUT
fi
- name: Let user know merging will cause a release
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
github-token: ${{ secrets.WEAVE_GITOPS_BOT_ACCESS_TOKEN }}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Merging this will release a new helm chart. ${{ steps.extra.outputs.unreleased-commits }}"
})
helm-release:
runs-on: ubuntu-latest
needs: helm-new-version
if: (github.event_name == 'push' && needs.helm-new-version.outputs.old-version != needs.helm-new-version.outputs.new-version) || github.event_name == 'workflow_dispatch'
permissions:
packages: write # needed for ghcr access
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Find new version
id: new_version
run: |
NEW_VERSION=$(yq e '.version' charts/gitops-server/Chart.yaml)
echo "version=$NEW_VERSION" >> $GITHUB_OUTPUT
- name: Generate new chart
run: |
mkdir helm-release
helm package charts/gitops-server/ -d helm-release
- name: Log in to the Container registry
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Publish chart as an OCI image
run: |
helm push helm-release/weave-gitops-${{ steps.new_version.outputs.version }}.tgz oci://ghcr.io/weaveworks/charts