Skip to content

diff checker

diff checker #811

Workflow file for this run

name: diff checker
on:
schedule:
- cron: '0 23 * * *'
workflow_dispatch:
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"