Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: 👷 add worflow to update chart #67

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
79 changes: 79 additions & 0 deletions .github/workflows/update-chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Update chart

on:
workflow_call:
inputs:
CHART_NAME:
description: Name of the folder chart (in /charts)
required: true
type: string
APP_VERSION:
description: The app version to inject in Chart.yaml
required: true
type: string
UPGRADE_TYPE:
description: Should update 'major', 'minor' or 'patch'
required: false
type: string
default: patch

workflow_dispatch:
inputs:
CHART_NAME:
description: Name of the folder chart (in /charts)
required: true
type: choice
options:
- dso-backup-utils
- dso-cnpg
- dso-console
- dso-env
- dso-infra-argocd
- dso-ns
APP_VERSION:
description: The app version to inject in Chart.yaml
required: true
type: string
UPGRADE_TYPE:
description: Should update 'major', 'minor' or 'patch'
required: false
type: choice
options:
- major
- minor
- patch
default: patch

jobs:
update:
name: Update a chart version
runs-on: ubuntu-latest
steps:
- name: Checks-out repository
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: latest

- name: update chart version
id: update-chart
run: |
npm i -g semver
CHART_VERSION=$(yq .version charts/${{ inputs.CHART_NAME }}/Chart.yaml)
NEXT_VERSION=$(semver -i ${{ inputs.UPGRADE_TYPE }} $CHART_VERSION)
sed -i "s/appVersion: .*/appVersion: ${{ inputs.APP_VERSION }}/" charts/${{ inputs.CHART_NAME }}/Chart.yaml
sed -i "s/version: .*/version: $NEXT_VERSION/" charts/${{ inputs.CHART_NAME }}/Chart.yaml

docker run --rm --volume "$(pwd)/charts/${{ inputs.CHART_NAME }}:/helm-docs" -u $(id -u) jnorwood/helm-docs:latest
git co -b ${{ inputs.CHART_NAME }}-$NEXT_VERSION
git commit -m "chore: :arrow_up: upgrade ${{ inputs.CHART_NAME }} to ${{ inputs.APP_VERSION }}" -a
git push --set-upstream origin ${{ inputs.CHART_NAME }}-$NEXT_VERSION
echo "BRANCH_PR=${{ inputs.CHART_NAME }}-$NEXT_VERSION" >> $GITHUB_OUTPUT

- name: Create pull request
uses: peter-evans/[email protected]
with:
branch: ${{ steps.update-chart.outputs.BRANCH_PR }}
base: main