[CI] Update CI

Signed-off-by: Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs <me@bjw-s.dev>
This commit is contained in:
Bᴇʀɴᴅ Sᴄʜᴏʀɢᴇʀs 2021-06-12 16:22:34 +02:00
parent fce43fdc84
commit 417dd63006
No known key found for this signature in database
GPG Key ID: 228A77789D71A6E2
3 changed files with 78 additions and 209 deletions

View File

@ -1,173 +0,0 @@
name: "Charts: Auto-generate docs"
on:
workflow_dispatch:
repository_dispatch:
types: [update-readme-command]
pull_request:
paths:
- 'charts/**/Chart.yaml'
- 'charts/**/values.yaml'
- 'charts/**/*.md.gotmpl'
- 'charts/**/README.md'
concurrency:
group: ${{ github.head_ref }}-generate-docs
cancel-in-progress: true
jobs:
# Branch-based pull request / workflow_dispatch
generate-readme-trusted:
if:
(
github.event_name == 'pull_request' &&
github.event.pull_request.head.repo.full_name == github.repository
) ||
github.event_name == 'workflow_dispatch'
name: Auto-generate chart README
runs-on: ubuntu-20.04
steps:
- name: Get k8s-at-home token
id: get-app-token
uses: getsentry/action-github-app-token@v1
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.get-app-token.outputs.token }}
ref: ${{ github.ref }}
fetch-depth: 0
- uses: dorny/paths-filter@v2
id: filter
with:
list-files: shell
filters: |
addedOrModified:
- added|modified: 'charts/**'
- name: Install Helm
if: steps.filter.outputs.addedOrModified == 'true'
uses: azure/setup-helm@v1
with:
version: v3.5.3
- uses: actions/setup-python@v2
if: steps.filter.outputs.addedOrModified == 'true'
with:
python-version: 3.7
- name: Install helm-docs
if: steps.filter.outputs.addedOrModified == 'true'
run: |
wget -O /tmp/helm-docs.deb https://github.com/norwoodj/helm-docs/releases/download/v1.5.0/helm-docs_1.5.0_linux_amd64.deb
sudo dpkg -i /tmp/helm-docs.deb
- name: Run against changed charts
if: steps.filter.outputs.addedOrModified == 'true'
run: |
CHARTS=()
PATHS=(${{ steps.filter.outputs.addedOrModified_files }})
# Get only the chart paths
for i in "${PATHS[@]}"
do
IFS='/' read -r -a path_parts <<< "$i"
CHARTS+=("${path_parts[1]}/${path_parts[2]}")
done
# Remove duplicates
CHARTS=( `for i in ${CHARTS[@]}; do echo $i; done | sort -u` )
for i in "${CHARTS[@]}"
do
echo "Rendering README for chart ${i}"
IFS='/' read -r -a chart_parts <<< "$i"
./hack/gen-helm-docs.sh "${chart_parts[0]}" "${chart_parts[1]}"
echo ""
done
- name: Create commit
if: steps.filter.outputs.addedOrModified == 'true'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Auto-generate 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>
file_pattern: charts/**/
# Repo owner has commented /update-readme on a (fork-based) pull request
generate-readme-fork:
if:
github.event_name == 'repository_dispatch'
name: Auto-generate chart README for forks
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
with:
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
fetch-depth: 0
- uses: dorny/paths-filter@v2
id: filter
with:
list-files: shell
base: master
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
filters: |
addedOrModified:
- added|modified: 'charts/**'
- name: Install Helm
if: steps.filter.outputs.addedOrModified == 'true'
uses: azure/setup-helm@v1
with:
version: v3.5.3
- uses: actions/setup-python@v2
if: steps.filter.outputs.addedOrModified == 'true'
with:
python-version: 3.7
- name: Install helm-docs
if: steps.filter.outputs.addedOrModified == 'true'
run: |
wget -O /tmp/helm-docs.deb https://github.com/norwoodj/helm-docs/releases/download/v1.5.0/helm-docs_1.5.0_linux_amd64.deb
sudo dpkg -i /tmp/helm-docs.deb
- name: Run against changed charts
if: steps.filter.outputs.addedOrModified == 'true'
run: |
CHARTS=()
PATHS=(${{ steps.filter.outputs.addedOrModified_files }})
# Get only the chart paths
for i in "${PATHS[@]}"
do
IFS='/' read -r -a path_parts <<< "$i"
CHARTS+=("${path_parts[1]}/${path_parts[2]}")
done
# Remove duplicates
CHARTS=( `for i in ${CHARTS[@]}; do echo $i; done | sort -u` )
for i in "${CHARTS[@]}"
do
echo "Rendering README for chart ${i}"
IFS='/' read -r -a chart_parts <<< "$i"
./hack/gen-helm-docs.sh "${chart_parts[0]}" "${chart_parts[1]}"
echo ""
done
- name: Create commit
if: steps.filter.outputs.addedOrModified == 'true'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Auto-generate 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>
file_pattern: charts/**/

View File

@ -9,15 +9,88 @@ on:
- master
paths:
- 'charts/**'
- '!charts/README.md'
- '!charts/**/README.md'
- '!charts/**/README.md.gotmpl'
- '!charts/**/README_CHANGELOG.md.gotmpl'
- '!charts/**/README_CONFIG.md.gotmpl'
jobs:
generate-readme:
name: Auto-generate chart README
runs-on: ubuntu-20.04
steps:
- name: Get k8s-at-home token
id: get-app-token
uses: getsentry/action-github-app-token@v1
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.get-app-token.outputs.token }}
ref: ${{ github.ref }}
fetch-depth: 0
- uses: dorny/paths-filter@v2
id: filter
with:
list-files: shell
filters: |
addedOrModified:
- added|modified: 'charts/**'
- name: Install Helm
if: steps.filter.outputs.addedOrModified == 'true'
uses: azure/setup-helm@v1
with:
version: v3.5.3
- uses: actions/setup-python@v2
if: steps.filter.outputs.addedOrModified == 'true'
with:
python-version: 3.7
- name: Install helm-docs
if: steps.filter.outputs.addedOrModified == 'true'
run: |
wget -O /tmp/helm-docs.deb https://github.com/norwoodj/helm-docs/releases/download/v1.5.0/helm-docs_1.5.0_linux_amd64.deb
sudo dpkg -i /tmp/helm-docs.deb
- name: Run against changed charts
if: steps.filter.outputs.addedOrModified == 'true'
run: |
CHARTS=()
PATHS=(${{ steps.filter.outputs.addedOrModified_files }})
# Get only the chart paths
for i in "${PATHS[@]}"
do
IFS='/' read -r -a path_parts <<< "$i"
CHARTS+=("${path_parts[1]}/${path_parts[2]}")
done
# Remove duplicates
CHARTS=( `for i in ${CHARTS[@]}; do echo $i; done | sort -u` )
for i in "${CHARTS[@]}"
do
echo "Rendering README for chart ${i}"
IFS='/' read -r -a chart_parts <<< "$i"
./hack/gen-helm-docs.sh "${chart_parts[0]}" "${chart_parts[1]}"
echo ""
done
- name: Create commit
if: steps.filter.outputs.addedOrModified == 'true'
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Auto-generate 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>
file_pattern: charts/**/
release:
runs-on: ubuntu-20.04
needs:
- generate-readme
steps:
- name: Checkout
uses: actions/checkout@v2

View File

@ -1,31 +0,0 @@
name: Dispatch Commands
on:
issue_comment:
types: [created]
jobs:
# If someone with write access comments "/update-readme" on a pull request, emit a repository_dispatch event
update-readme:
runs-on: ubuntu-latest
# Only run for PRs, not issue comments
if: ${{ github.event.issue.pull_request }}
steps:
- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v1
with:
app_id: ${{ secrets.K8S_AT_HOME_APP_ID }}
private_key: ${{ secrets.K8S_AT_HOME_APP_PRIVATE_KEY }}
- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v1
env:
TOKEN: ${{ steps.generate_token.outputs.token }}
with:
token: ${{ env.TOKEN }} # GitHub App installation access token generated above
reaction-token: ${{ secrets.GITHUB_TOKEN }}
issue-type: pull-request
commands: update-readme
named-args: true
permission: write