Skip to content

Commit 895d5aa

Browse files
authored
Merge pull request #60 from mikeshng/helm-chart-github-action
chore: add helm chart push
2 parents 587622d + d538d72 commit 895d5aa

File tree

3 files changed

+79
-3
lines changed

3 files changed

+79
-3
lines changed

.github/workflows/chart-upload.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: ChartUpload
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
release:
8+
types: [published]
9+
10+
env:
11+
CHART_NAME: cluster-permission
12+
13+
jobs:
14+
env:
15+
name: prepare release env
16+
runs-on: ubuntu-latest
17+
steps:
18+
- name: checkout code
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 1
22+
- name: get release version
23+
id: get_release_version
24+
run: |
25+
RELEASE_VERSION=${GITHUB_REF#refs/tags/}
26+
echo "::set-output name=RELEASE_VERSION::${RELEASE_VERSION}"
27+
echo "::set-output name=MAJOR_RELEASE_VERSION::${RELEASE_VERSION%.*}"
28+
echo "::set-output name=TRIMMED_RELEASE_VERSION::${RELEASE_VERSION#v}"
29+
outputs:
30+
RELEASE_VERSION: ${{ steps.get_release_version.outputs.RELEASE_VERSION }}
31+
MAJOR_RELEASE_VERSION: ${{ steps.get_release_version.outputs.MAJOR_RELEASE_VERSION }}
32+
TRIMMED_RELEASE_VERSION: ${{ steps.get_release_version.outputs.TRIMMED_RELEASE_VERSION }}
33+
upload:
34+
name: upload
35+
runs-on: ubuntu-latest
36+
needs: [ env ]
37+
permissions:
38+
contents: write
39+
steps:
40+
- name: submit charts to OCM chart repo
41+
if: github.event_name != 'pull_request'
42+
uses: actions/github-script@v7
43+
with:
44+
github-token: ${{ secrets.OCM_BOT_PAT }}
45+
script: |
46+
try {
47+
const result = await github.rest.actions.createWorkflowDispatch({
48+
owner: 'open-cluster-management-io',
49+
repo: 'helm-charts',
50+
workflow_id: 'download-chart.yml',
51+
ref: 'main',
52+
inputs: {
53+
repo: "${{ github.repository }}",
54+
version: "${{ needs.env.outputs.TRIMMED_RELEASE_VERSION }}",
55+
"chart-name": "${{ env.CHART_NAME }}",
56+
},
57+
})
58+
console.log(result);
59+
} catch(error) {
60+
console.error(error);
61+
core.setFailed(error);
62+
}

.github/workflows/go-release.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ env:
1010
GO_REQUIRED_MIN_VERSION: ''
1111
GOPATH: '/home/runner/work/cluster-permission/cluster-permission/go'
1212
GITHUB_REF: ${{ github.ref }}
13+
CHART_NAME: cluster-permission
1314

1415
defaults:
1516
run:
@@ -39,6 +40,14 @@ jobs:
3940
- name: get major release version
4041
run: |
4142
echo "MAJOR_RELEASE_VERSION=${RELEASE_VERSION%.*}" >> $GITHUB_ENV
43+
- name: setup helm
44+
uses: azure/setup-helm@v4
45+
- name: chart package
46+
run: |
47+
mkdir -p release
48+
pushd release
49+
helm package ../chart/
50+
popd
4251
- name: push image
4352
run: |
4453
echo ${{ secrets.DOCKER_PASSWORD }} | docker login quay.io --username ${{ secrets.DOCKER_USER }} --password-stdin
@@ -50,8 +59,13 @@ jobs:
5059
echo "- See the [CHANGELOG](https://github.com/open-cluster-management-io/cluster-permission/blob/main/CHANGELOG/CHANGELOG-${MAJOR_RELEASE_VERSION}.md) for more details." >> /home/runner/work/changelog.txt
5160
echo "- The released image is quay.io/open-cluster-management/cluster-permission:$RELEASE_VERSION" >> /home/runner/work/changelog.txt
5261
- name: publish release
53-
uses: softprops/action-gh-release@v0.1.5
62+
uses: softprops/action-gh-release@v2
5463
env:
5564
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
5665
with:
5766
body_path: /home/runner/work/changelog.txt
67+
files: |
68+
release/*.tgz
69+
draft: true
70+
prerelease: false
71+
generate_release_notes: true

chart/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
2-
appVersion: 1.16.0
2+
appVersion: 0.14.0
33
description: A controller for managing RBAC resources to the managed clusters.
44
name: cluster-permission
55
type: application
6-
version: 2.3.0
6+
version: 0.14.0

0 commit comments

Comments
 (0)