File tree Expand file tree Collapse file tree 2 files changed +75
-0
lines changed
Expand file tree Collapse file tree 2 files changed +75
-0
lines changed Original file line number Diff line number Diff line change 1+ # golang-pre-commit
2+
3+ This is a collection of golang [pre-commit](http://pre-commit.com/) hooks.
Original file line number Diff line number Diff line change 1+ name : " Update Readme"
2+
3+ on :
4+ release :
5+ types : [published]
6+ workflow_dispatch :
7+
8+ jobs :
9+ publish :
10+ runs-on : ubuntu-latest
11+ steps :
12+ - name : Checkout
13+ uses : actions/checkout@v4
14+ with :
15+ fetch-depth : 0
16+ token : ${{ secrets.RELEASE_PLEASE_TOKEN }}
17+ ref : main
18+
19+ - name : Generate README.md
20+ shell : bash
21+ run : |
22+ set -euo pipefail
23+
24+ # Fail early if yq isn't installed
25+ if ! command -v yq > /dev/null 2>&1
26+ then
27+ echo "yq is not installed!"
28+ exit 1
29+ fi
30+
31+ declare RM_HEADER
32+ declare RM_DEST
33+ declare HOOK_CONTENT
34+ declare LATEST_VER
35+
36+ LATEST_VER="$(git describe --tags --abbrev=0)"
37+
38+ HOOK_CONTENT=""
39+
40+ RM_HEADER=".github/README.md.header"
41+ RM_DEST="README.md"
42+
43+ for hook in $(yq -r '.[].id' < .pre-commit-hooks.yaml)
44+ do
45+ HOOK_CONTENT+="* \`$hook\`"
46+ HOOK_CONTENT+=" - $(hook="$hook" yq -r '.[] | select(.id == env(hook)) | .description' < .pre-commit-hooks.yaml)\n"
47+ done
48+
49+ # Open FD 3 for RM_DEST
50+ exec 3<> "$RM_DEST"
51+
52+ cat "$RM_HEADER" >&3
53+ echo -ne "## Usage\n\n" >&3
54+ echo -ne '```yaml\n' >&3
55+ echo -ne ' - repo: https://github.com/bhundven/golang-pre-commit.git\n' >&3
56+ echo -ne " rev: ${LATEST_VER}\n" >&3
57+ echo -ne ' hooks:\n' >&3
58+ echo -ne '```\n\n' >&3
59+
60+ echo -ne "## Available Hooks\n\n" >&3
61+ echo -ne "$HOOK_CONTENT" >&3
62+
63+ # Close FD 3
64+ exec 3>&-
65+
66+ - name : Push Changes
67+ uses : EndBug/add-and-commit@v9
68+ with :
69+ committer_name : GitHub Actions
70+ committer_email :
[email protected] 71+ add : README.md
72+ message : ' chore: Update README.md for release'
You can’t perform that action at this time.
0 commit comments