-
Notifications
You must be signed in to change notification settings - Fork 3
90 lines (86 loc) · 2.82 KB
/
refresh.yml
File metadata and controls
90 lines (86 loc) · 2.82 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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@v6
- name: checkout docs
uses: actions/checkout@v6
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: check-spelling-bot@users.noreply.github.com
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'
changes=$(mktemp)
git diff "$old_commit" --stat > "$changes"
if [ ! -s "$changes" ]; then
echo '## No changes'
fi
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
if [ -s "$changes" ]; then
echo '---'
echo '```diff'
cat "$changes"
echo '```'
fi
orphans=$(mktemp)
# Make sure when no files are found that '*.md' is not the value of the variable
shopt -s nullglob
../find-orphaned-pages.pl *.md > "$orphans"
if [ -s "$orphans" ]; then
echo
echo '## Orphans'
echo
for a in $(cat "$orphans"); do
echo '* `'"$a"'`'
done
echo
fi
) >> "$GITHUB_STEP_SUMMARY"
if ! git push origin HEAD --force-with-lease; then
git log -p FETCH_HEAD..HEAD | cat
fi
check-spelling:
needs: refresh
permissions:
actions: read
contents: read
pull-requests: read
security-events: write
uses: check-spelling/check-spelling-docs/.github/workflows/spelling.yml@main