Skip to content

chore: update kb-vision to 0.12.1 #437

chore: update kb-vision to 0.12.1

chore: update kb-vision to 0.12.1 #437

name: Release Chart on PR Merge
on:
pull_request:
types: [closed]
branches: [main]
jobs:
trigger-release:
name: Tag and Release Chart
if: |
github.event.pull_request.merged == true &&
contains(github.event.pull_request.labels.*.name, 'chart-update')
runs-on: ubuntu-latest
permissions:
contents: write # Required to push tags
actions: write # Required to dispatch workflow_dispatch
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract chart info from PR
id: extract
run: |
PR_BRANCH="${{ github.event.pull_request.head.ref }}"
# Extract chart name and version from branch name
# Format: update-{chart-name}-{version}
if [[ "$PR_BRANCH" =~ ^update-([a-zA-Z0-9-]+)-([0-9]+\.[0-9]+\.[0-9]+)$ ]]; then
CHART_NAME="${BASH_REMATCH[1]}"
VERSION="${BASH_REMATCH[2]}"
echo "chart_name=$CHART_NAME" >> $GITHUB_OUTPUT
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Chart: $CHART_NAME"
echo "Version: $VERSION"
else
echo "::error::Could not parse chart info from branch: $PR_BRANCH"
exit 1
fi
- name: Verify chart version in Chart.yaml
run: |
CHART_NAME="${{ steps.extract.outputs.chart_name }}"
EXPECTED="${{ steps.extract.outputs.version }}"
CHART_VERSION=$(yq '.version' "./charts/$CHART_NAME/Chart.yaml")
if [ "$CHART_VERSION" != "$EXPECTED" ]; then
echo "::error::Chart.yaml version ($CHART_VERSION) does not match expected ($EXPECTED)"
exit 1
fi
echo "Chart.yaml version matches: $CHART_VERSION"
- name: Create release tag
run: |
TAG_NAME="${{ steps.extract.outputs.chart_name }}-v${{ steps.extract.outputs.version }}"
if git rev-parse "$TAG_NAME" >/dev/null 2>&1; then
echo "Tag $TAG_NAME already exists, skipping tag creation"
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "$TAG_NAME" -m "Release ${{ steps.extract.outputs.chart_name }} v${{ steps.extract.outputs.version }}
Chart version: ${{ steps.extract.outputs.version }}
Automated release from PR #${{ github.event.pull_request.number }}"
# Push with GITHUB_TOKEN — tag won't trigger other workflows,
# but that's fine since we dispatch helm-release.yaml explicitly below.
git push origin "$TAG_NAME"
echo "Created tag: $TAG_NAME"
fi
- name: Trigger chart release workflow
env:
GH_TOKEN: ${{ github.token }}
run: |
CHART="${{ steps.extract.outputs.chart_name }}"
VERSION="v${{ steps.extract.outputs.version }}"
echo "Dispatching helm-release.yaml for $CHART $VERSION..."
gh workflow run helm-release.yaml \
--field chart="$CHART" \
--field version="$VERSION"
echo "Dispatched release workflow for $CHART $VERSION"
echo "Monitor: https://github.com/${{ github.repository }}/actions/workflows/helm-release.yaml"