1+ name : Build and Release Extension Charts
2+
3+ on :
4+ workflow_dispatch :
5+ release :
6+ types : [released]
7+
8+ env :
9+ ACTIONS_RUNNER_DEBUG : false
10+ CI_COMMIT_MESSAGE : CI Build Artifacts
11+ TARGET_BRANCH : gh-pages
12+
13+ defaults :
14+ run :
15+ shell : bash
16+ working-directory : ./
17+
18+ jobs :
19+ build-extension-artifact :
20+ name : Build extension artifact
21+ runs-on : ubuntu-latest
22+ permissions :
23+ actions : write
24+ contents : read
25+ steps :
26+ - name : Checkout
27+ uses : actions/checkout@v3
28+ with :
29+ fetch-depth : 0
30+
31+ - name : Configure Git
32+ run : |
33+ git config user.name 'github-actions[bot]'
34+ git config user.email 'github-actions[bot]@users.noreply.github.com'
35+
36+ - name : Setup Helm
37+ uses : azure/setup-helm@v3
38+ with :
39+ version : v3.8.0
40+
41+ - name : Setup yq
42+ uses : chrisdickinson/setup-yq@v1.0.1
43+ with :
44+ yq-version : v4.34.2
45+
46+ - name : Setup Nodejs and npm
47+ uses : actions/setup-node@v3
48+ with :
49+ node-version : ' 16'
50+
51+ - name : Setup yarn
52+ run : npm install -g yarn
53+
54+ - name : Setup Nodejs with yarn caching
55+ uses : actions/setup-node@v3
56+ with :
57+ node-version : ' 16'
58+ cache : yarn
59+
60+ - name : Install dependencies
61+ run : yarn
62+
63+ - name : Parse Extension Name
64+ if : github.ref_type == 'tag'
65+ id : parsed-name
66+ env :
67+ GH_TOKEN : ${{ github.token }}
68+ run : |
69+ chmod +x ./node_modules/@rancher/shell/scripts/extension/parse-tag-name
70+ yarn parse-tag-name ${{ github.ref_name }} ${{ github.run_id }} "charts"
71+
72+ - name : Run build script
73+ shell : bash
74+ id : build_script
75+ run : |
76+ publish="yarn publish-pkgs -s ${{ github.repository }} -b ${{ env.TARGET_BRANCH }}"
77+
78+ if [[ -n "${{ github.ref_name }}" ]]; then
79+ publish="$publish -t ${{ github.ref_name }}"
80+ fi
81+
82+ $publish
83+
84+ - name : Upload charts artifact
85+ if : github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
86+ uses : actions/upload-artifact@v3
87+ with :
88+ name : charts
89+ path : tmp
90+
91+ release :
92+ name : Release Build
93+ if : github.ref_type == 'tag' || (github.ref == 'refs/heads/main' && github.event_name != 'pull_request')
94+ needs : build-extension-artifact
95+ runs-on : ubuntu-latest
96+ permissions :
97+ actions : write
98+ contents : write
99+ deployments : write
100+ pages : write
101+ steps :
102+ - name : Checkout
103+ uses : actions/checkout@v3
104+ with :
105+ ref : " ${{ env.TARGET_BRANCH }}"
106+
107+ - name : Configure Git
108+ run : |
109+ git config user.name 'github-actions[bot]'
110+ git config user.email 'github-actions[bot]@users.noreply.github.com'
111+
112+ - name : Download build artifact
113+ uses : actions/download-artifact@v3
114+ with :
115+ name : charts
116+
117+ - name : Commit build
118+ run : |
119+ git add ./{assets,charts,extensions,index.yaml}
120+ git commit -a -m "${{ env.CI_COMMIT_MESSAGE }}"
121+ git push
122+
123+ - name : Run chart-releaser
124+ uses : helm/chart-releaser-action@v1.4.1
125+ with :
126+ charts_dir : ./charts/*
127+ env :
128+ CR_TOKEN : ' ${{ secrets.GITHUB_TOKEN }}'
129+ CR_SKIP_EXISTING : true
0 commit comments