ci: 👷 GH actions : update ref-style docs on push

This commit is contained in:
Mike Cunneen 2025-08-21 18:55:05 +08:00
parent 51a270bad1
commit 7111c55fa7
2 changed files with 24 additions and 10 deletions

View file

@ -11,6 +11,7 @@
# get a reference to the current directory # get a reference to the current directory
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
READMEFILE="${DIR}/../../../README.md" READMEFILE="${DIR}/../../../README.md"
OUTFILE="${DIR}/../../../docs/REFERENCE_STYLE.md"
# extract the table rows from README.md, sort them, and pass them to # extract the table rows from README.md, sort them, and pass them to
# the awk script to generate the reference-style link for each row. # the awk script to generate the reference-style link for each row.
@ -22,9 +23,9 @@ readmerows=$(
) )
# add a newline before processing with awk # add a newline before processing with awk
printf "%s\n" "$readmerows" \ printf "%s\n\n" "$readmerows" \
| awk -F '|' -f "${DIR}/extract-refstyle-badges.awk" \ | gawk --posix -F '|' -f "${DIR}/extract-refstyle-badges.awk" \
> md-badges.md > "${DIR}/md-badges.md"
# now insert the generated md-badges.md content into README.md # now insert the generated md-badges.md content into README.md
@ -34,11 +35,9 @@ tail='^<\!-- ### END GENERATED CONTENT -->'
sed -e "/$lead/,/$tail/{ sed -e "/$lead/,/$tail/{
/$lead/{ /$lead/{
p; p;
r md-badges.md r $DIR/md-badges.md
}; };
/$tail/p; /$tail/p;
d d
}" "${READMEFILE}" > "${READMEFILE}.tmp" }" "${READMEFILE}" > "${OUTFILE}.tmp"
mv "${READMEFILE}.tmp" "${READMEFILE}" mv "${OUTFILE}.tmp" "${OUTFILE}"
# echo "${READMEFILE}"

View file

@ -7,8 +7,23 @@ on:
- feature/reference-style-table - feature/reference-style-table
jobs: jobs:
extract-refstyle-badges: extract-refstyle-badges:
runs-on: ubuntu-latest runs-on: ubuntu-22.04
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v5.0.0
- name: update apt
run: apt-get update
- name: install gawk and git
run: apt-get install -y gawk git
- name: extract refstyle badges - name: extract refstyle badges
run: ${{github.workspace}}/.github/scripts/extract-refstyle-badges/extract-refstyle-badges.sh run: ${{github.workspace}}/.github/scripts/extract-refstyle-badges/extract-refstyle-badges.sh
- name: display modified README in GH action logs
run: cat ${{github.workspace}}/docs/REFERENCE_STYLE.md
- name: commit changes
run: |
# Note: the following account information will not work on GHES
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add ${{github.workspace}}/docs/REFERENCE_STYLE.md
git commit -m "[bot] update reference-style table"
git status
git push