-
Notifications
You must be signed in to change notification settings - Fork 3
119 lines (104 loc) · 4.04 KB
/
helm-builder.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
117
118
119
# Pull the GitHub Runner Scale Set Controller OCI Artifact
# and convert it to a standard Helm tar.gz file and push it
# to this repository for use with tools like Kustomize.
name: GitHub Runner Scale Set Controller Helm Builder
run-name: ${{github.actor}} - GitHub Runner Scale Set Controller Helm Builder
on:
pull_request:
types:
- closed
branches:
- main
env:
# renovate: datasource=docker
GHRSS_VERSION: "ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set:0.9.0"
# renovate: datasource=docker
GHRSSC_VERSION: "ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller:0.8.3"
# renovate: datasource=github-releases depName=helm/chart-releaser
CR_VERSION: "v1.6.1"
# Branch name where GitHub Pages are published
# https://docs.github.com/en/pages/getting-started-with-github-pages/configuring-a-publishing-source-for-your-github-pages-site
PAGES_BRANCH: "gh-pages"
jobs:
helm:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true
permissions:
contents: write
packages: write
strategy:
max-parallel: 1
matrix:
chartName: [GHRSSC_VERSION, GHRSS_VERSION]
steps:
- name: Clone Repository
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4
with:
fetch-depth: 0
- name: Install required tools
run: |
sudo apt-get update
sudo apt-get install -y \
skopeo wget file git
- name: install chart-releaser
run: |
if [ ! -f ./cr ]; then
version="${{env.CR_VERSION}}"
wget -qO- \
https://github.com/helm/chart-releaser/releases/download/${version}/chart-releaser_${version#v}_linux_amd64.tar.gz | \
tar -xvz -C ./
fi
- name: Copy and Download the OCI Artifact
id: copy
run: |
mkdir -p arc
# Check for the matrix, set the chart URL and clone it
if [[ "${{ matrix.chartName }}" == "GHRSSC_VERSION" ]]; then
chart="${{ env.GHRSSC_VERSION }}"
elif [[ "${{ matrix.chartName }}" == "GHRSS_VERSION" ]]; then
chart="${{ env.GHRSS_VERSION }}"
fi
skopeo copy docker://${chart} dir:./arc
# Output
echo "chart=${chart}" >> "$GITHUB_OUTPUT"
- name: Find and extract the Helm Chart
id: extract
run: |
for file in $(find arc -type f); do
if [[ $(file $file --mime-type | awk '{print $2}') == "application/gzip" ]]; then
tar -zxvf $file
break
fi
done
# Output
echo "directory=$(ls | grep gha)" >> "$GITHUB_OUTPUT"
- name: Package the GitHub Action Runner Scale Set Helm Chart
run: |
package="$(echo "${{ steps.copy.outputs.chart }}" | awk -F\/ '{print $4}' | cut -d: -f1)"
./cr package ${package}/
- name: Upload Helm Chart to GitHub
run: |
./cr upload \
--owner ${{github.event.repository.owner.login}} \
--git-repo ${{github.event.repository.name}} \
--token ${{secrets.GITHUB_TOKEN}} \
--skip-existing \
--push
- name: Set Git User values
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
# https://github.com/helm/chart-releaser/issues/187
- name: Create and push the Helm Index to GitHub
run: |
# Verify that the PAGES_BRANCH exists on origin
git show-ref origin ${{env.PAGES_BRANCH}} || ( echo "Branch ${{env.PAGES_BRANCH}} does not exist on origin" && exit 1 )
mkdir -p .cr-index
git fetch --all
./cr index \
--owner ${{github.event.repository.owner.login}} \
--git-repo ${{github.event.repository.name}} \
--token ${{secrets.GITHUB_TOKEN}} \
--index-path . \
--pages-branch ${{env.PAGES_BRANCH}} \
--push