-
Notifications
You must be signed in to change notification settings - Fork 2
116 lines (102 loc) · 3.28 KB
/
callBuildChart.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: Call Build Chart
env:
PR_LABEL: pr/release/robot_update_githubpage
PR_REVIWER: weizhoublue
MERGE_BRANCH: github_pages
on:
workflow_call:
inputs:
chart_path:
required: true
type: string
code_sha:
required: true
type: string
permissions: write-all
jobs:
package_chart:
runs-on: ubuntu-latest
outputs:
code_sha: ${{ env.code_sha }}
steps:
- name: Get information
run: |
echo '${{ toJSON(github) }}'
# when CI trigger by PR and call this yaml, it appears ${{ github.event_name == 'pull_request' }}
#if ${{ inputs.ref != '' }}; then
echo "code_sha=${{ inputs.code_sha }}" >> $GITHUB_ENV
echo "chart_path=${{ inputs.chart_path }}" >> $GITHUB_ENV
#else
# eixt 1
#fi
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ env.code_sha }}
- name: Install Helm
uses: azure/setup-helm@v4
#with:
# version: ${{ env.HELM_VERSION }}
- name: Package Chart
continue-on-error: false
run: |
helm package ${{ env.chart_path }}
if ! ls *.tgz &>/dev/null ; then
echo "failed to generate chart"
exit 1
fi
mkdir -p tmp
mv *.tgz tmp
- name: Upload Artifact
uses: actions/[email protected]
with:
name: chart_package_artifact
path: tmp/*
retention-days: 1
if-no-files-found: error
# update /index.yaml in the target branch
update_githubpage:
runs-on: ubuntu-latest
needs: [package_chart]
steps:
- name: Get Base Chart URL
id: get_base_url
run: |
name=${{ github.repository }}
proj=${name#*/}
url=https://${{ github.repository_owner }}.github.io/${proj}
echo "URL=${url}" >> $GITHUB_ENV
- name: Checkout Code
uses: actions/checkout@v4
with:
ref: ${{ env.MERGE_BRANCH }}
persist-credentials: "true"
- name: Download Artifact
uses: actions/download-artifact@v3
with:
name: chart_package_artifact
path: charts/
- name: Update Chart Yaml
run: |
helm repo index ./charts --url ${{ env.URL }}/charts
mv ./charts/index.yaml ./index.yaml
- uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Create Pull Request
uses: peter-evans/[email protected]
with:
title: "robot Update chart from ${{ needs.get_ref.outputs.code_sha }} to branch ${{ env.MERGE_BRANCH }} "
commit-message: "robot Update chart from ${{ needs.get_ref.outputs.code_sha }} to branch ${{ env.MERGE_BRANCH }} "
branch-suffix: timestamp
branch: robot/update_chart
committer: ty-dc <[email protected]>
delete-branch: true
base: ${{ env.MERGE_BRANCH }}
signoff: true
token: ${{ secrets.GITHUB_TOKEN }}
labels: ${{ env.PR_LABEL }}
reviewers: ${{ env.PR_REVIWER }}