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

220 lines
8.1 KiB
YAML
Raw Normal View History

2022-03-30 06:26:37 -04:00
name: "Charts: Release"
concurrency: helm-release
on:
workflow_dispatch:
push:
branches:
- master
paths:
- "charts/**"
jobs:
release:
runs-on: ubuntu-latest
container:
image: ghcr.io/truecharts/devcontainer:v2.2.1@sha256:4ace13c049bf00f85c63e0070f86b71656a7c3b2113aa3e21c3107f3d1f7bf87
concurrency: gitpush
steps:
- name: Install Kubernetes tools
uses: yokawasa/action-setup-kube-tools@c81bf94cddd6c3172e6f61aa7f5ad66a2b5db98d # tag=v0.8.0
2022-03-30 06:26:37 -04:00
with:
2022-03-30 08:59:33 -04:00
setup-tools: |
helmv3
helm: "3.8.0"
2022-03-30 06:26:37 -04:00
- 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-old https://truecharts.org
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 add amd-gpu-helm https://radeonopencompute.github.io/k8s-device-plugin/
helm repo update
- name: Checkout
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3
with:
token: ${{ secrets.BOT_TOKEN }}
fetch-depth: 50
- name: Collect changes
id: collect-changes
uses: ./.github/actions/collect-changes
- name: Generate README for changed charts
2022-04-01 05:34:46 -04:00
shell: bash
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
run: |
CHARTS=(${{ steps.collect-changes.outputs.modifiedChartsAfterTag }})
.github/scripts/gen-docs.sh ${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
2022-04-01 02:39:13 -04:00
- name: Checkout
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3
with:
fetch-depth: 1
repository: truecharts/pub
token: ${{ secrets.BOT_TOKEN }}
path: pub
2022-04-01 02:34:12 -04:00
- name: Copy docs to website
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
2022-04-01 03:27:52 -04:00
shell: bash
2022-04-01 02:34:12 -04:00
run: |
2022-04-01 03:17:25 -04:00
#!/bin/bash
CHARTS=(${{ steps.collect-changes.outputs.modifiedChartsAfterTag }})
2022-04-01 02:56:49 -04:00
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}"
2022-04-01 03:17:25 -04:00
mkdir -p docs/apps/${train}/${chart} || echo "app path already exists, continuing..."
2022-04-01 02:56:49 -04:00
yes | cp -rf charts/${train}/${chart}/README.md pub/website/apps/${train}/${chart}/index.md 2>/dev/null || :
yes | cp -rf charts/${train}/${chart}/CHANGELOG.md pub/website/apps/${train}/${chart}/CHANGELOG.md 2>/dev/null || :
yes | cp -rf charts/${train}/${chart}/security.md pub/website/apps/${train}/${chart}/security.md 2>/dev/null || :
yes | cp -rf charts/${train}/${chart}/CONFIG.md pub/website/apps/${train}/${chart}/CONFIG.md 2>/dev/null || :
yes | cp -rf charts/${train}/${chart}/helm-values.md pub/website/apps/${train}/${chart}/helm-values.md 2>/dev/null || :
rm pub/website/apps/${train}/${chart}/LICENSE.md 2>/dev/null || :
yes | cp -rf charts/${train}/${chart}/LICENSE pub/website/apps/${train}/${chart}/LICENSE.md 2>/dev/null || :
sed -i '1s/^/# License<br>\n\n/' pub/website/apps/${train}/${chart}/LICENSE.md 2>/dev/null || :
fi
done
2022-04-01 02:34:12 -04:00
- name: Create commit
id: create-commit
uses: stefanzweifel/git-auto-commit-action@c4b132ec2c77a21fcab564bd3c92610cee84b894 # 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
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 pub
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
## TODO: actually push the content
# git push
cd -
rm -rf pub
- name: Checkout
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3
with:
fetch-depth: 1
repository: truecharts/catalog
token: ${{ secrets.BOT_TOKEN }}
path: catalog
- name: Checkout
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3
with:
fetch-depth: 1
repository: truecharts/dh_catalog
token: ${{ secrets.BOT_TOKEN }}
path: dh_catalog
- name: build catalogs
shell: bash
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
run: |
pip install yq
CHARTS=(${{ steps.collect-changes.outputs.modifiedChartsAfterTag }})
.github/scripts/build-catalog.sh ${CHARTS}
- name: Validate catalogs
if: |
steps.collect-changes.outputs.changesDetectedAfterTag == 'true'
run: |
echo "Starting Catalog Validation"
/usr/local/bin/catalog_validate validate --path "${PWD}/catalog"
- 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 App releases for TrueCharts" || exit 0
## TODO: actually push the content
# git push
cd -
rm -rf catalog
- name: Commit DH Catalog
if: |
steps.collect-changes.outputs.changesDetected == 'true'
run: |
cd dh_catalog
git config user.name "TrueCharts-Bot"
git config user.email "bot@truecharts.org"
git add --all
git commit -sm "Commit new App releases for TrueCharts" || exit 0
## TODO: actually push the content
# git push
cd -
rm -rf dh_catalog
2022-03-30 06:26:37 -04:00
- name: Checkout
uses: actions/checkout@a12a3943b4bdde767164f792f33f40b04645d846 # tag=v3
2022-03-30 06:26:37 -04:00
with:
token: ${{ secrets.BOT_TOKEN }}
ref: ${{ steps.save-commit-hash.outputs.commit_hash }}
fetch-depth: 0
- 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@a3454e46a6f5ac4811069a381e646961dda2e1bf # tag=v1.4.0
2022-03-30 06:26:37 -04:00
with:
charts_dir: charts/*
charts_repo_url: https://charts.truecharts.org
env:
CR_TOKEN: "${{ secrets.BOT_TOKEN }}"
CR_SKIP_EXISTING: "true"