Skip to content

Commit

Permalink
feat(workflow): create pipeline to update chart (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoSaba authored Dec 11, 2024
1 parent 7f29ec3 commit a909c79
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/bump-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: "Update Helm Chart Tag"

on:
workflow_dispatch:
inputs:
new_version:
description: 'New version to update'
required: true
type: string
repository_dispatch:
types: [update-helm-chart-version]

permissions:
actions: read
contents: write
pull-requests: write

env:
CI_COMMIT_AUTHOR: bump-version-wf
CI_COMMIT_EMAIL: [email protected]
HELM_BRANCH: master
HELM_BRANCH_MERGE: "feat(helm)/update-to-"
CHART_FILE: charts/kestra/Chart.yaml

jobs:
update-helm-chart:
runs-on: ubuntu-latest

steps:
- name: Set HELM_VERSION
id: set-helm-version
run: |
if [ -n "${{ github.event.client_payload.new_version }}" ]; then
echo "HELM_BRANCH_MERGE=${{ env.HELM_BRANCH_MERGE }}${{ github.event.client_payload.new_version }}" >> $GITHUB_ENV
echo "HELM_VERSION=${{ github.event.client_payload.new_version }}" >> $GITHUB_ENV
else
echo "HELM_BRANCH_MERGE=${{ env.HELM_BRANCH_MERGE }}${{ github.event.client_payload.new_version }} >> $GITHUB_ENV
echo "HELM_VERSION=${{ inputs.new_version }}" >> $GITHUB_ENV
fi
echo "version: ${HELM_VERSION#v}"
echo "appVersion: ${HELM_VERSION}"
echo "HELM_BRANCH_MERGE: ${HELM_BRANCH_MERGE}"
- name: Checkout master branch
uses: actions/checkout@v4
with:
ref: ${{ env.HELM_BRANCH }}

- name: Update Tag in YAML File
id: edit-chart-version
env:
HELM_VERSION: ${{ env.HELM_VERSION }}
run: |
git config user.name "${{ env.CI_COMMIT_AUTHOR }}"
git config user.email "${{ env.CI_COMMIT_EMAIL }}"
# Update the appVersion with the new tag
yq e -i ".appVersion = \"${HELM_VERSION}\"" ${{ env.CHART_FILE }}
# Update the version with the new tag, removing the leading 'v'
yq e -i ".version = \"${HELM_VERSION#v}\"" ${{ env.CHART_FILE }}
git add ${{ env.CHART_FILE }}
git commit -m "Update version to ${HELM_VERSION#v} and appVersion to ${HELM_VERSION}"
- name: Create Pull Request
id: create-pr
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_ACCESS_TOKEN }}
branch: ${{ env.HELM_BRANCH_MERGE }}
delete-branch: true
title: 'Helm chart update to ${HELM_VERSION#v}'
body: |
Helm Chart update to new version:
- In ${{ env.CHART_FILE }} new version is ${HELM_VERSION#v}
- In ${{ env.CHART_FILE }} new appVersion is ${HELM_VERSION}
- Auto-generated by "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|Action URL>"
labels: |
automated pr

0 comments on commit a909c79

Please sign in to comment.