Skip to content

Commit

Permalink
add repos when publishing with cr-releaser
Browse files Browse the repository at this point in the history
  • Loading branch information
smileisak committed Feb 26, 2025
1 parent 7cf242f commit e63046c
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 16 deletions.
15 changes: 0 additions & 15 deletions .github/configs/ct-lint.yaml

This file was deleted.

29 changes: 29 additions & 0 deletions .github/workflows/charts-publish.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
name: Chart Publish

on:
push:
branches:
- fix/ci
pull_request:
branches:
- main
types:
- closed
workflow_dispatch: # Optional: Allows manual triggering from the Actions tab

permissions:
contents: read
Expand All @@ -18,23 +22,44 @@ jobs:
contents: write # for helm/chart-releaser-action to push chart release and create a release
packages: write # to push OCI chart package to GitHub Registry
steps:
# Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

# Set up Helm
- name: Set up Helm
uses: azure/setup-helm@v4.3.0

# Install yq
- name: Install yq
run: |
sudo wget -qO /usr/bin/yq https://github.com/mikefarah/yq/releases/download/v4.30.2/yq_linux_amd64
sudo chmod +x /usr/bin/yq
# Add dependency chart repos
- name: Add dependency chart repos
run: |
for chart in charts/*; do
if [[ -f "$chart/Chart.yaml" ]]; then
helm dependency update "$chart"
fi
done
# Configure Git
- name: Configure Git
run: | # $GITHUB_ACTOR: last user who trigger the action
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
# Add Helm Repositories
- name: Add Helm Repositories
run: |
chmod +x ./scripts/add-repos.sh
./scripts/add-repos.sh
# Lint the charts
- name: Fetch current Chart Index from gh-pages
run: |
git checkout origin/gh-pages index.yaml || echo "No index.yaml found; skipping."
Expand All @@ -47,13 +72,17 @@ jobs:
# env:
# PGP_PRIVATE_KEY: "${{ secrets.PGP_PRIVATE_KEY }}"
# PGP_PASSPHRASE: "${{ secrets.PGP_PASSPHRASE }}"

# Run Chart Releaser
- name: Run Chart Releaser
uses: helm/chart-releaser-action@v1.7.0
with:
config: "./.github/configs/cr.yaml"
packages_with_index: true
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

# Push OCI Helm Chart Packages to GHCR
- name: Login to GitHub Container Registry (GHCR)
uses: docker/login-action@v3
with:
Expand Down
32 changes: 32 additions & 0 deletions scripts/add-repos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash
set -euo pipefail

CONFIG_FILE=".github/configs/ct.yaml"

# Check if the configuration file exists
if [[ ! -f "$CONFIG_FILE" ]]; then
echo "Error: Configuration file '$CONFIG_FILE' not found!"
exit 1
fi

# Ensure yq is installed (https://github.com/mikefarah/yq)
if ! command -v yq &> /dev/null; then
echo "Error: 'yq' is not installed. Please install it to parse the YAML file."
exit 1
fi

# Extract the chart repositories from the YAML file.
# It will output entries like "dex=https://charts.dexidp.io"
repos=$(yq e '.["chart-repos"][]' "$CONFIG_FILE")

echo "Adding helm repositories from $CONFIG_FILE..."
# Iterate over each repository entry and add it using helm repo add.
while IFS= read -r repo_entry; do
# Split the entry at '=' into a name and URL.
repo_name="${repo_entry%%=*}"
repo_url="${repo_entry#*=}"
echo "Adding repo: $repo_name -> $repo_url"
helm repo add "$repo_name" "$repo_url"
done <<< "$repos"

echo "All helm repositories added successfully."
2 changes: 1 addition & 1 deletion scripts/lint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ docker run -it --rm \
--workdir /workdir \
quay.io/helmpack/chart-testing:v3.12.0 \
ct lint \
--config .github/configs/ct-lint.yaml \
--config .github/configs/ct.yaml \
--lint-conf .github/configs/lintconf.yaml \
--debug

0 comments on commit e63046c

Please sign in to comment.