TrueChartsClone/.github/workflows/charts-release.yaml

230 lines
8.6 KiB
YAML

name: "Charts: Release"
concurrency: helm-release
on:
workflow_dispatch:
push:
branches:
- master
paths:
- "charts/**"
jobs:
release-scale:
runs-on: ubuntu-latest
container:
image: ghcr.io/truecharts/devcontainer:v2.6.0@sha256:5029ebed5c833646da3afb3a8512eba79f08cac8935a53fc1510854fec22341a
steps:
- name: Install Kubernetes tools
uses: yokawasa/action-setup-kube-tools@f7f73d7965074b0f5491b7210ff51e3254d42058 # tag=v0.8.2
with:
setup-tools: |
helmv3
helm: "3.8.0"
- name: Install helm-docs
run: |
wget -O /tmp/helm-docs.deb https://github.com/k8s-at-home/helm-docs/releases/download/v0.1.1/helm-docs_0.1.1_Linux_x86_64.deb
sudo dpkg -i /tmp/helm-docs.deb
- name: Prep Helm
run: |
helm repo add truecharts https://charts.truecharts.org
helm repo add truecharts-library https://library-charts.truecharts.org
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add metallb https://metallb.github.io/metallb
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add prometheus https://prometheus-community.github.io/helm-charts
helm repo update
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
with:
token: ${{ secrets.BOT_TOKEN }}
fetch-depth: 0
- name: Collect changes
id: collect-changes
uses: ./.github/actions/collect-changes
- name: Generate README for changed charts
shell: bash
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
run: |
CHARTS=(${{ steps.collect-changes.outputs.modifiedChartsAfterTag }})
parthreads=$(($(nproc) * 2))
parallel -j ${parthreads} .github/scripts/gen-docs.sh '2>&1' ::: ${CHARTS[@]}
- name: Fix Pre-Commit issues
shell: bash
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
run: |
echo "Running pre-commit test-and-cleanup..."
pre-commit run --all ||:
# Fix sh files to always be executable
find . -name '*.sh' | xargs chmod +x
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
with:
fetch-depth: 1
repository: truecharts/website
token: ${{ secrets.BOT_TOKEN }}
path: website
- name: Copy docs to website
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
shell: bash
run: |
#!/bin/bash
CHARTS=(${{ steps.collect-changes.outputs.modifiedChartsAfterTag }})
echo "Removing Chart Docs prior to regeneration..."
mkdir -p website/static/img/hotlink-ok/chart-icons || echo "chart-icons path already exists, continuing..."
for i in "${CHARTS[@]}"
do
IFS='/' read -r -a chart_parts <<< "$i"
if [ -f "charts/${chart_parts[0]}"/"${chart_parts[1]}/Chart.yaml" ]; then
train=${chart_parts[0]}
chart=${chart_parts[1]}
echo "copying docs to website for ${chart}"
rm -rf website/docs/charts/*/${chart}
mkdir -p website/docs/charts/${train}/${chart} || echo "chart path already exists, continuing..."
yes | cp -rf charts/${train}/${chart}/README.md website/docs/charts/${train}/${chart}/index.md 2>/dev/null || :
yes | cp -rf charts/${train}/${chart}/CHANGELOG.md website/docs/charts/${train}/${chart}/CHANGELOG.md 2>/dev/null || :
yes | cp -rf charts/${train}/${chart}/docs/* website/docs/charts/${train}/${chart}/ 2>/dev/null || :
yes | cp -rf charts/${train}/${chart}/icon.png website/static/img/hotlink-ok/chart-icons/${chart}.png 2>/dev/null || :
fi
done
- name: Create commit
id: create-commit
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
uses: stefanzweifel/git-auto-commit-action@49620cd3ed21ee620a48530e81dba0d139c9cb80 # tag=v4
with:
file_pattern: charts/**/
commit_message: "chore: Auto-update chart README [skip ci]"
commit_user_name: truecharts-bot
commit_user_email: bot@truecharts.org
commit_author: truecharts-bot <bot@truecharts.org>
- name: Save commit hash
id: save-commit-hash
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
run: |
if [ "${{ steps.create-commit.outputs.changes_detected || 'unknown' }}" = "true" ]; then
echo '::set-output name=commit_hash::${{ steps.create-commit.outputs.commit_hash }}'
else
echo "::set-output name=commit_hash::${GITHUB_SHA}"
fi
- name: Commit Website Changes
if: |
steps.collect-changes.outputs.changesDetected == 'true'
run: |
cd website
git config user.name "TrueCharts-Bot"
git config user.email "bot@truecharts.org"
git add --all
git commit -sm "Commit released docs for TrueCharts" || exit 0
git push
cd -
rm -rf website
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
with:
fetch-depth: 1
repository: truecharts/catalog
token: ${{ secrets.BOT_TOKEN }}
ref: staging
path: catalog
- name: build catalogs
shell: bash
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
run: |
pip install yq
CHARTS=(${{ steps.collect-changes.outputs.modifiedChartsAfterTag }})
parthreads=$(($(nproc) * 2))
parallel -j ${parthreads} .github/scripts/build-catalog.sh '2>&1' ::: ${CHARTS[@]}
- name: Commit Catalog
if: |
steps.collect-changes.outputs.changesDetected == 'true'
run: |
cd catalog
git config user.name "TrueCharts-Bot"
git config user.email "bot@truecharts.org"
git add --all
git commit -sm "Commit new Chart releases for TrueCharts" || exit 0
git push
cd -
rm -rf catalog
release-helm:
runs-on: ubuntu-latest
container:
image: ghcr.io/truecharts/devcontainer:v2.6.0@sha256:5029ebed5c833646da3afb3a8512eba79f08cac8935a53fc1510854fec22341a
needs: release-scale
steps:
- name: Install Kubernetes tools
uses: yokawasa/action-setup-kube-tools@f7f73d7965074b0f5491b7210ff51e3254d42058 # tag=v0.8.2
with:
setup-tools: |
helmv3
helm: "3.8.0"
- name: Install helm-docs
run: |
wget -O /tmp/helm-docs.deb https://github.com/k8s-at-home/helm-docs/releases/download/v0.1.1/helm-docs_0.1.1_Linux_x86_64.deb
sudo dpkg -i /tmp/helm-docs.deb
- name: Prep Helm
run: |
helm repo add truecharts https://charts.truecharts.org
helm repo add truecharts-library https://library-charts.truecharts.org
helm repo add bitnami https://charts.bitnami.com/bitnami
helm repo add metallb https://metallb.github.io/metallb
helm repo add grafana https://grafana.github.io/helm-charts
helm repo add prometheus https://prometheus-community.github.io/helm-charts
helm repo update
- name: Checkout
uses: actions/checkout@2541b1294d2704b0964813337f33b291d3f8596b # tag=v3
with:
token: ${{ secrets.BOT_TOKEN }}
fetch-depth: 0
- name: Fix Pre-Commit issues
shell: bash
run: |
echo "Running pre-commit test-and-cleanup..."
pre-commit run --all ||:
# Fix sh files to always be executable
find . -name '*.sh' | xargs chmod +x
- name: Configure Git
run: |
git config user.name "truecharts-bot"
git config user.email "bot@truecharts.org"
- name: Run chart-releaser
uses: helm/chart-releaser-action@98bccfd32b0f76149d188912ac8e45ddd3f8695f # tag=v1.4.1
with:
charts_dir: charts/*
charts_repo_url: https://charts.truecharts.org
env:
CR_TOKEN: "${{ secrets.BOT_TOKEN }}"
CR_SKIP_EXISTING: "true"