Initial commit. #1
This file contains hidden or 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
name: Publish MediaWiki Helm Chart to GHCR | |
on: | |
push: | |
branches: | |
- main # Or your default branch like 'master' or 'develop' | |
paths: | |
# Adjust these paths to your actual chart location and workflow file | |
- 'helm/**' | |
- '.github/workflows/publish-mediawiki-chart.yaml' | |
jobs: | |
publish: | |
name: Publish Helm Chart | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read # Required to checkout the repository code | |
packages: write # Required to push packages to GHCR | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Helm 3 (and verify version) | |
uses: azure/setup-helm@v1 | |
with: | |
# Explicitly request a Helm 3 version that supports OCI push | |
version: 'v3.15.0' | |
id: setup_helm | |
- name: Verify Helm Version is 3.x | |
run: | | |
helm version --client | |
# Check if the client version string contains "v3." | |
helm version --client | grep "Version:\"v3\." || { | |
echo "Error: Helm 3 was not correctly installed. Found different version." | |
exit 1 | |
} | |
- name: Clean Helm Cache and Ensure Home Directory | |
run: | | |
echo "Cleaning Helm cache directory: ~/.helm" | |
rm -rf ~/.helm || true # Remove the entire directory, ignore if it doesn't exist | |
mkdir -p ~/.helm/repository | |
touch ~/.helm/repository/repositories.yaml | |
touch ~/.helm/registry.json # This will be populated by helm registry login | |
- name: Login to GitHub Container Registry | |
run: | | |
echo "${{ secrets.GITHUB_TOKEN }}" | helm registry login ghcr.io \ | |
--username ${{ github.actor }} \ | |
--password-stdin | |
- name: Get Chart Version and Name | |
id: get_chart_info | |
run: | | |
CHART_NAME=$(yq e '.name' helm/Chart.yaml) | |
CHART_VERSION=$(yq e '.version' helm/Chart.yaml) | |
echo "Chart Name: $CHART_NAME" | |
echo "Chart Version: $CHART_VERSION" | |
echo "chart_name=$CHART_NAME" >> "$GITHUB_OUTPUT" | |
echo "chart_version=$CHART_VERSION" >> "$GITHUB_OUTPUT" | |
- name: Add Helm repository | |
run: helm repo add bcgov-crunchy-postgres https://bcgov.github.io/crunchy-postgres/ | |
# Update the chart dependencies | |
- name: Update Helm dependencies | |
run: helm dependency update ./helm | |
# Package the Helm Chart | |
- name: Package Helm Chart | |
run: helm package helm | |
- name: Push Helm Chart to GHCR | |
run: | | |
CHART_PACKAGE_NAME="${{ steps.get_chart_info.outputs.chart_name }}-${{ steps.get_chart_info.outputs.chart_version }}.tgz" | |
CHART_OCI_PATH="oci://ghcr.io/${{ github.repository_owner }}/${{ steps.get_chart_info.outputs.chart_name }}" | |
echo "Pushing $CHART_PACKAGE_NAME to $CHART_OCI_PATH" | |
helm push "$CHART_PACKAGE_NAME" "$CHART_OCI_PATH" |