danmanners - GitHub Runner Scale Set Controller Helm Builder #67
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.3" | |
# renovate: datasource=docker | |
GHRSSC_VERSION: "ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-set-controller:0.9.0" | |
# 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@b4ffde65f46336ab88eb53be808477a3936bae11 # 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 |