Skip to content

Commit

Permalink
Enforce up-to-date docs via GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
anttiharju committed Sep 1, 2024
1 parent 03f0c61 commit 032487d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 17 deletions.
17 changes: 1 addition & 16 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,21 +1,6 @@
#!/bin/sh
set -eu

if ! git diff --quiet --staged; then
echo "You have staged changes; cannot ensure docs are up-to-date."
exit 1
fi

./scripts/g.sh

if git diff --quiet -- bin/g; then
exit 0
fi

git add bin/g
name="github-actions[bot]"
email="41898282+github-actions[bot]@users.noreply.github.com"
GIT_COMMITTER_NAME="$name" GIT_COMMITTER_EMAIL="$email" git commit --no-verify -m \
"Update bin/g docs
./scripts/update-g-docs.sh "
via .githooks/pre-push"
21 changes: 21 additions & 0 deletions .github/workflows/update-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Update docs
on:
push:
branches:
- main
pull_request:
paths:
- 'bin/g*'
permissions:
contents: write

jobs:
g:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
scripts/update-g-docs.sh
git push
2 changes: 1 addition & 1 deletion bin/g
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ set -eu

# DO NOT EDIT MANUALLY! THIS SCRIPT IS GENERATED BY g.sh

echo "gc [0;31mGit Clear[0m discard all uncommited changes. Change
echo "gc [0;31mGit Clear[0m discard all uncommited changes.
glo Git Log Oneline sensible defaults based on context. Alternatively print N commits 'glo 5'.
gpr Git PR open the existing or a new PR for current branch. On default branch opens the repo."
22 changes: 22 additions & 0 deletions scripts/update-g-docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/sh
set -eu

if ! git diff --quiet --staged; then
echo "You have staged changes; cannot ensure docs are up-to-date."
exit 1
fi

./scripts/g.sh

if git diff --quiet -- bin/g; then
exit 0
fi

# Set source to empty string if $1 is unbound.
source="${1:-}"

git add bin/g
name="github-actions[bot]"
email="41898282+github-actions[bot]@users.noreply.github.com"
GIT_COMMITTER_NAME="$name" GIT_COMMITTER_EMAIL="$email" git commit --no-verify -m \
"Update bin/g docs$source"

0 comments on commit 032487d

Please sign in to comment.