-
Notifications
You must be signed in to change notification settings - Fork 3
60 lines (53 loc) · 2.05 KB
/
generate-readme.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: 'Update README Metadata'
on:
pull_request:
paths: ['charts/**']
types:
- opened
- edited
- reopened
- synchronize
permissions:
contents: read
jobs:
update-readme-metadata:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: read
steps:
- name: Install readme-generator-for-helm
run: npm install -g @bitnami/[email protected]
- uses: actions/checkout@v3
name: Checkout Conduktor Charts
with:
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Execute readme-generator-for-helm
env:
GH_TOKEN: ${{ github.token }}
TEMP_FILE: "${{runner.temp}}/pr-${{github.event.number}}.diff"
run: |
export PR_ID=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
gh pr diff ${PR_ID} > $TEMP_FILE
files_changed="$(sed -nr 's/[\-\+]{3} [ab]\/(.*)/\1/p' $TEMP_FILE | sort | uniq)"
# Adding || true to avoid "Process exited with code 1" errors
charts_dirs_changed="$(echo "$files_changed" | xargs dirname | grep -o "charts/[^/]*" | sort | uniq || true)"
for chart in ${charts_dirs_changed}; do
echo "Updating README.md for ${chart}"
readme-generator --values "${chart}/values.yaml" --readme "${chart}/README.md" --schema "/tmp/schema.json"
done
- name: Setup GPG
id: gpg
uses: crazy-max/[email protected]
with:
gpg_private_key: ${{ secrets.CONDUKTOR_BOT_GPG_PRIVATE_KEY }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Push changes
run: |
if git status -s | grep -E 'charts/.*/README.md'; then
git config user.name "${{ steps.gpg.outputs.name }}"
git config user.email "${{ steps.gpg.outputs.email }}"
git add . && git commit -S -am "chore(chart): Update README.md with readme-generator-for-helm" --signoff && git push
fi