update #70
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: update | |
permissions: | |
contents: write | |
on: | |
schedule: | |
- cron: '0 0 * * *' # every day | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
spider: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-python@v5 | |
with: | |
python-version: "3.11.x" | |
- run: python3 -m pip install requests | |
- run: python3 main.py > LATEST | |
- name: Commit files | |
id: commit-files | |
run: | | |
if [ -n "$(git status --porcelain database.json)" ]; then | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add . | |
git commit -m "$(cat LATEST)" | |
echo "hasChange=true" >> $GITHUB_OUTPUT | |
else | |
echo "No changes detected" | |
fi | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
if: ${{ steps.commit-files.outputs.hasChange == 'true' }} | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ github.ref }} | |
- name: Trigger deploy | |
if: ${{ steps.commit-files.outputs.hasChange == 'true' }} | |
run: | | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/AIboy996/bilibili_poster/dispatches \ | |
-d '{"event_type":"run-deploy","client_payload":{"unit":false,"integration":true}}' |