-
Notifications
You must be signed in to change notification settings - Fork 2
60 lines (58 loc) · 1.97 KB
/
refresh.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
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Refresh Docs
on:
workflow_dispatch:
jobs:
refresh:
name: Refresh Website Content
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: checkout workflow
uses: actions/checkout@v4
- name: checkout docs
uses: actions/checkout@v4
with:
fetch-depth: 0
path: gh-pages
ref: gh-pages
- 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: [email protected]
run: |
PATH=$(pwd):$PATH
cd gh-pages
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