Skip to content

Merge pull request #1372 from jenkins-infra/updatecli_main_e852c57d8b… #1077

Merge pull request #1372 from jenkins-infra/updatecli_main_e852c57d8b…

Merge pull request #1372 from jenkins-infra/updatecli_main_e852c57d8b… #1077

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@fe7b79cd5ee1e45176fcad797de68ecaf3ca4814 # v4.2.0
# 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