-
-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (37 loc) · 1.44 KB
/
diff-checker.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
name: diff checker
on:
schedule:
- cron: '0 23 * * *'
jobs:
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23
- name: Check diff
id: check-diff
run: |
GOBIN=${PWD}/bin go install github.com/suntong/[email protected]
curl https://go.dev/doc/faq | ./bin/html2md -i -G | sed -n -e 131,2411p > original.md
echo "diff=$(git diff --name-only original.md | wc -l | xargs )" >> $GITHUB_OUTPUT
- name: Create a PR if diff exists
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
if: ${{ steps.check-diff.outputs.diff != 0 }}
run: |
git config user.name ${GITHUB_ACTOR}
git config user.email ${GITHUB_ACTOR}@users.noreply.github.com
branch=feature/diff-$(TZ=JST-9 date +'%Y-%m-%d')
git switch -c ${branch}
git add original.md
git commit --message "update diff"
git push origin ${branch}
pr_number=$(gh pr list --search "Update site info in:title" --json number --jq '.[0].number')
if [ ! -z "$pr_number" ]; then
echo "Closing PR #$pr_number from yesterday"
gh pr close $pr_number --comment "Closing in favor of a new PR"
fi
gh pr create -B main -t "[$(date +'%Y-%m-%d')] Update site info" --body "Check the diff content"