forked from uw-psych/hyakvnc
-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (46 loc) · 1.85 KB
/
mkreadme.yml
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
name: Build documentation
on:
push:
jobs:
build-readme:
runs-on: ubuntu-latest
name: Build README.md
permissions:
contents: write
steps:
- name: Install jinja-cli
run: |
python3 -m pip install jinja-cli
- name: Check out code for the container build
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if README.md has changed
id: readme-changed
run: |
if ! git --no-pager diff --name-only --quiet --diff-filter=AM ${{ github.event.before }} ${{ github.event.after }} -- hyakvnc .build/README.j2.md .github/workflows/mkreadme.yml; then
gh run cancel ${{ github.run_id }}
gh run watch ${{ github.run_id }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Generate configuration descriptions
run: |
pushd .build/
sed -E '/^HYAKVNC_.*#\s*%%/!d; s/=.*(#\s*%%)/:/g; s/(^.)/- \1/g' ../hyakvnc > config.inc.md
popd
- name: Generate usage descriptions
run: |
pushd .build/
for x in create status show stop config install; do ../hyakvnc help "$x" | sed -E '1 s/(.*)/\n### \1\n/; 2 s/^$/```text/' | pr -e4 -t && echo '```'; done > usage.inc.md
popd
- name: Create and push README.md
run: |
pushd .build/
jinja -D github_repository "${{ github.repository }}" -D github_ref_name "${{ github.ref_name }}" README.j2.md | sed 's/^.*<!-- markdownlint-disable-file -->.*$//g' > ../README.md
popd
git config --local user.email "${{ github.event.sender.id }}+${{ github.event.sender.login }}@users.noreply.github.com"
git config --local user.name ${{ github.event.sender.login }}
git add README.md
git commit -am "Update README.md"
git push