Check quest update #1146
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check quest update | |
on: | |
schedule: | |
- cron: '0 0 * * *' # At every day 00:00(UTC). | |
workflow_dispatch: | |
jobs: | |
check: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [13.x] | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v1 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install | |
run: npm ci | |
- name: Check Update | |
id: check-update | |
run: npm run checkPoi | |
- name: Push Branch | |
id: push | |
run: | | |
git add draft outdated | |
# Do not proceed if there are no file differences | |
COMMIT=$(git rev-parse --verify origin/$TARGET_BRANCH || echo HEAD) | |
FILES_CHANGED=$(git diff-index --name-only --cached $COMMIT | wc -l) | |
if [[ "$FILES_CHANGED" = "0" ]]; then | |
echo "No file changes detected in draft." | |
echo "::set-output name=skipPR::true" | |
exit 0 | |
fi | |
git config user.name 'kcwikizh' | |
git config user.email 'dev@kcwiki.moe' | |
git commit --message 'feat(data): draft new quest' | |
git remote set-url origin "https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY" | |
git push --force origin HEAD:$TARGET_BRANCH | |
env: | |
GITHUB_TOKEN: ${{ secrets.github_token }} | |
TARGET_BRANCH: bot/new-quest | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y-%m-%d')" | |
# see https://github.com/repo-sync/pull-request | |
- name: Create Pull Request | |
if: steps.push.outputs.skipPR != 'true' | |
uses: repo-sync/pull-request@v2 | |
with: | |
source_branch: 'bot/new-quest' # If blank, default: triggered branch | |
pr_title: 'feta(data): draft new quest (${{ steps.date.outputs.date }})' # Title of pull request | |
pr_body: ${{ join(steps.check-update.outputs.*, '') }} # Full markdown support, requires pr_title to be set | |
pr_label: 'data,bot' # Comma-separated list (no spaces) | |
github_token: ${{ secrets.GITHUB_TOKEN }} |