Skip to content

Update the sub-charts #108

Update the sub-charts

Update the sub-charts #108

name: Update the sub-charts
on:
schedule:
- cron: "0 2 * * *" # daily at 2 AM UTC
workflow_dispatch:
inputs:
git_user_name:
description: 'Git user name'
required: true
default: 'github-actions[bot]'
git_user_email:
description: 'Git user email'
required: true
default: 'github-actions[bot]@users.noreply.github.com'
permissions:
contents: write
pull-requests: write
issues: read
concurrency:
group: auto-update-subcharts
cancel-in-progress: true
jobs:
update-subcharts:
runs-on: ubuntu-latest
steps:
- name: Install Act dependencies
if: ${{ env.ACT }}
run: |
apt-get update && apt-get install sudo gh -y
- name: Install dependencies
run: |
sudo apt-get update && sudo apt-get install curl ca-certificates tar gzip git bash build-essential gh -y
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # Required for PR creation and full history
persist-credentials: false # since we explicitly authenticate in a later step
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.15.4
- name: Install updatecli
run: |
mkdir -p $HOME/.local/bin
curl -sSL https://github.com/updatecli/updatecli/releases/latest/download/updatecli_Linux_x86_64.tar.gz -o updatecli.tar.gz
tar -xzf updatecli.tar.gz -C $HOME/.local/bin updatecli
echo "$HOME/.local/bin" >> $GITHUB_PATH
- name: Configure Git identity
run: |
git config --global user.name "${{ github.event.inputs.git_user_name || 'github-actions[bot]' }}"
git config --global user.email "${{ github.event.inputs.git_user_email || 'github-actions[bot]@users.noreply.github.com' }}"
- name: Authenticate Git
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git
- name: Run updatecli
run: |
helm registry login ${{ secrets.APPCO_REGISTRY }} -u ${{ secrets.APPCO_USER }} -p ${{ secrets.APPCO_TOKEN }}
updatecli apply --config .updatecli/update.yml
- name: Run helm dependency update
run: |
helm registry login ${{ secrets.APPCO_REGISTRY }} -u ${{ secrets.APPCO_USER }} -p ${{ secrets.APPCO_TOKEN }}
helm dependency update
- name: Lint Helm Chart
run: |
helm lint .
- name: Commit Changes
run: |
# Stage Chart.yaml only if there are real differences
if ! git diff --quiet Chart.yaml; then
git add Chart.yaml
fi
# Stage Chart.lock
git add Chart.lock
# Stage added or modified .tgz files in charts/
find charts -name "*.tgz" -type f -print0 | xargs -0 git add
# Remove deleted .tgz files from index
git ls-files -d '*.tgz' | xargs -r git rm
if git ls-files --error-unmatch updatecli.tar.gz >/dev/null 2>&1; then
git rm updatecli.tar.gz
else
rm -f updatecli.tar.gz
fi
# debug info before commit
echo "==== git status ===="
git status
echo "==== staged diff ===="
git --no-pager diff --cached
# Commit only if index changed
if ! git diff-index --cached --quiet HEAD; then
git commit -m "chore: update subchart versions"
else
echo "No changes to commit"
fi
# debug info after commit
echo "==== final status ===="
git status
- name: Create Pull Request
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.GITHUB_TOKEN }}
#branch: auto-update-subcharts
base: main
title: "chore: update subchart versions"
body: |
Automated PR to update subchart dependencies. Generated by GHA workflow.
labels: "auto-update-subcharts"
commit-message: "chore: update subchart versions"
delete-branch: true