debt: Support for Kubernetes 1.30+ (#2) #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ref: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions | |
name: publish | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- charts/** | |
- .github/workflows/publish.yaml | |
jobs: | |
publish: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read # Required to read repo contents | |
packages: write # Required to push to GHCR | |
steps: | |
- name: Preamble | |
run: | | |
whoami | |
echo github ref $GITHUB_REF | |
echo workflow $GITHUB_WORKFLOW | |
echo home $HOME | |
echo event name $GITHUB_EVENT_NAME | |
echo workspace $GITHUB_WORKSPACE | |
sudo apt update && sudo apt install -y yq | |
df -h | |
# Ref: https://github.com/actions/checkout | |
- name: Checkout Source | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
# Ref: https://github.com/Azure/setup-helm | |
- name: Install Helm | |
uses: azure/setup-helm@v4 | |
with: | |
version: v3.16.2 | |
# Authenticate to GHCR | |
- name: Login to GitHub Container Registry | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io --username ${{ github.actor }} --password-stdin | |
# Ref: https://github.com/helm/chart-testing-action | |
- name: Install chart-testing | |
uses: helm/[email protected] | |
# Detect changed charts. | |
# Ref: https://github.com/helm/chart-testing-action | |
- name: Run chart-testing (list-changed) | |
id: list-changed | |
run: | | |
changed=$(ct list-changed --config ct.yaml) | |
if [[ -n "$changed" ]]; then | |
echo "changed=true" >> "$GITHUB_OUTPUT" | |
echo "charts=$changed" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Run chart-testing (lint) | |
if: steps.list-changed.outputs.changed == 'true' | |
run: ct lint --config ct.yaml | |
# Publish Changed Charts. | |
- name: Publish Charts | |
if: steps.list-changed.outputs.changed == 'true' | |
run: | | |
for chart in ${{ steps.list-changed.outputs.charts }}; do | |
echo "Processing chart: $chart" | |
# Extract chart version from Chart.yaml | |
VERSION=$(yq e '.version' charts/$chart/Chart.yaml) | |
# Package the chart | |
helm package charts/$chart --destination ./charts-packaged | |
# Save and push the chart to GHCR | |
helm chart save ./charts-packaged/$chart-$VERSION.tgz ghcr.io/${{ github.repository_owner }}/$chart:$VERSION | |
helm chart push ghcr.io/${{ github.repository_owner }}/$chart:$VERSION | |
done |