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

150 lines
4.6 KiB
YAML
Raw Normal View History

2021-01-11 01:29:16 +00:00
name: "Charts: Release"
concurrency: helm-release
on:
2021-03-18 12:18:14 +00:00
workflow_dispatch:
push:
branches:
- master
paths:
- "charts/**"
jobs:
release:
runs-on: ubuntu-20.04
steps:
- name: Generate Token
uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.K8S_AT_HOME_APP_ID }}
private_key: ${{ secrets.K8S_AT_HOME_APP_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ steps.generate-token.outputs.token }}
ref: master
fetch-depth: 0
- name: Install Kubernetes tools
uses: yokawasa/action-setup-kube-tools@v0.8.0
with:
setup-tools: |
helmv3
yq
helm: 3.6.3
yq: "4.16.2"
- 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: Collect changed files
uses: dorny/paths-filter@v2
id: filter
with:
list-files: shell
filters: |
addedOrModified:
- added|modified: 'charts/**'
- name: Collect changed charts
if: |
steps.filter.outputs.addedOrModified == 'true'
id: filter-charts
run: |
CHARTS=()
PATHS=(${{ steps.filter.outputs.addedOrModified_files }})
# Get only the chart paths
for CHARTPATH in "${PATHS[@]}"
do
IFS='/' read -r -a path_parts <<< "${CHARTPATH}"
CHARTS+=("${path_parts[1]}/${path_parts[2]}")
done
# Remove duplicates
CHARTS=( `printf "%s\n" "${CHARTS[@]}" | sort -u` )
# Set output to changed charts
printf "::set-output name=addedOrModified::%s\n" "${CHARTS[*]}"
- name: Generate README for changed charts in Renovate PR's
if: |
steps.filter.outputs.addedOrModified == 'true'
run: |
CHARTS=(${{ steps.filter-charts.outputs.addedOrModified }})
for i in "${CHARTS[@]}"
do
IFS='/' read -r -a chart_parts <<< "$i"
if [ -f "charts/${chart_parts[0]}"/"${chart_parts[1]}/Chart.yaml" ]; then
./.github/scripts/gen-helm-docs.sh "${chart_parts[0]}" "${chart_parts[1]}"
fi
done
- name: Create commit
id: create-commit
uses: stefanzweifel/git-auto-commit-action@v4
with:
file_pattern: charts/**/
commit_message: "chore: Auto-update chart README"
commit_user_name: k8s-at-home[bot]
commit_user_email: k8s-at-home[bot]@users.noreply.github.com
commit_author: k8s-at-home[bot] <k8s-at-home[bot]@users.noreply.github.com>
- name: Configure Git
if: steps.create-commit.outputs.changes_detected == 'false'
run: |
git config user.name "k8s-at-home[bot]"
git config user.email "k8s-at-home[bot]@users.noreply.github.com"
- name: Run chart-releaser
if: steps.create-commit.outputs.changes_detected == 'false'
uses: helm/chart-releaser-action@v1.2.1
with:
charts_dir: charts/*
charts_repo_url: https://k8s-at-home.com/charts/
env:
CR_TOKEN: "${{ steps.generate-token.outputs.token }}"
CR_SKIP_EXISTING: "true"
generate-summary:
name: Auto-generate charts summary
runs-on: ubuntu-20.04
needs:
- release
steps:
- name: Generate Token
uses: tibdex/github-app-token@v1
id: generate-token
with:
app_id: ${{ secrets.K8S_AT_HOME_APP_ID }}
private_key: ${{ secrets.K8S_AT_HOME_APP_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v2
with:
token: ${{ steps.generate-token.outputs.token }}
ref: master
fetch-depth: 0
- name: Install yq
uses: chrisdickinson/setup-yq@latest
with:
yq-version: v4.9.3
- name: Run script
run: |
./hack/gen-chart-summary.sh
- name: Create Commit
uses: stefanzweifel/git-auto-commit-action@v4
with:
push_options: --force
commit_message: Auto-generate chart summary [no ci]
commit_user_name: k8s-at-home[bot]
commit_user_email: k8s-at-home[bot]@users.noreply.github.com
commit_author: k8s-at-home[bot] <k8s-at-home[bot]@users.noreply.github.com>
file_pattern: charts/README.md