Skip to content

bump: a subject

bump: a subject #18

Workflow file for this run

name: Release Charts
on:
push:
branches:
- main
paths:
- 'charts/**'
# Only allow 1 release at a time (avoid concurent deployment to gh-pages)
concurrency: "release-chart"
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Install Helm
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5
with:
token: ${{ secrets.GITHUB_TOKEN }}
# Needed for subchart dependencies
- name: Add jenkins-infra Helm repository
run: helm repo add jenkins-infra https://jenkins-infra.github.io/helm-charts
- name: Run chart-releaser
id: chart_releaser
uses: helm/chart-releaser-action@a917fd15b20e8b64b94d9158ad54cd6345335584 # v1.6.0
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Update modified chart release(s)
id: update_chart_releases
if: steps.chart_releaser.outputs.changed_charts != ''
run: |
# KISS, last commit subject as changelog for every modified chart
changelog=$(git log --format=%s -n 1)
# Set IFS to a comma to split the string into an array
IFS=',' read -ra changedCharts <<< "${{ steps.chart_releaser.outputs.changed_charts }}"
for chart in "${changedCharts[@]}"; do
chartName=$(echo "${chart}" | cut -d '/' -f 2)
# Retrieve version from Chart.yaml
version=$(yq '.version' "${chart}/Chart.yaml")
# Retrive release id and body from tag
tag="${chartName}-${version}"
release=$(curl --location --silent --fail --show-error "https://api.github.com/repos/${{ github.repository }}/releases/tags/${tag}")
releaseId=$(echo "${release}" | jq --raw-output '.id')
releaseBody=$(echo "${release}" | jq --raw-output '.body')
# Update release
newlines="\r\n\r\n"
body="${releaseBody}${newlines}## Changelog${newlines}${changelog}"
echo "= release description for ${tag}:"
echo "${body}"
curl --silent --fail --show-error --output /dev/null --location \
-X PATCH \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
--header "X-GitHub-Api-Version: 2022-11-28" \
"https://api.github.com/repos/${{ github.repository }}/releases/${releaseId}" \
--data "{\"body\":\"${body}\"}"
done