Skip to content

Commit

Permalink
Add refresh workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
jsoref committed Sep 3, 2023
1 parent 6ded1b8 commit 151d6cd
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
54 changes: 54 additions & 0 deletions .github/workflows/refresh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Refresh Docs

on:
workflow_dispatch:

jobs:
refresh:
name: Refresh Website Content
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: checkout docs
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: update docs
shell: bash
env:
wiki: https://github.com/check-spelling/check-spelling.wiki.git
GIT_COMMITTER_NAME: check-spelling-bot
GIT_COMMITTER_EMAIL: check-spelling-bot@users.noreply.github.com
run: |
set -x
old_commit=$(git rev-parse HEAD)
latest_commit_message="$(git log --pretty=format:%s -1)"
if [ "Convert for docs" != "$latest_commit_message" ] ; then
echo "::error ::Unexpected commit message: '$latest_commit_message'"
exit 1
fi
git reset --hard "$old_commit"~
git remote add wiki "${wiki:-https://github.com/check-spelling/check-spelling.wiki.git}"
git fetch wiki
git rebase FETCH_HEAD
./build.sh
git add -u
git config user.email "$GIT_COMMITTER_EMAIL"
git config user.name "$GIT_COMMITTER_NAME"
git commit -m "$latest_commit_message"
new_commit=$(git rev-parse HEAD)
(
echo '# Refresh website'
URL_BASE="$GITHUB_SERVER_URL/$GITHUB_REPOSITORY"
echo "[Updates]($URL_BASE/compare/$old_commit..$new_commit) • [All Changes]($URL_BASE/compare/$old_commit...$new_commit)"
echo "[$old_commit]($URL_BASE/commit/$old_commit) :arrow_right: [$new_commit]($URL_BASE/commit/$new_commit)"
echo
echo '---'
echo '```'
git diff "$old_commit" --stat
echo '```'
) >> "$GITHUB_STEP_SUMMARY"
if ! git push origin HEAD --force-with-lease; then
git log -p FETCH_HEAD..HEAD | cat
fi
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ for maybe_missing_eol in ./*.md; do
echo >> "$maybe_missing_eol"
fi
done
if [ -s _Footer.md ]; then
if [ -s _Footer.md ]; then
footer=$(head -1 _Footer.md)
git ls-files '*.md' -z |
footer="$footer" ./add-footer.pl
Expand Down

0 comments on commit 151d6cd

Please sign in to comment.