Skip to content

精简workflow

精简workflow #6

Workflow file for this run

name: auto update
on:
schedule:
- cron: '0 0 * * *' # every day
push:
branches:
- main
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
spider:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
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
if: ${{ steps.commit-files.outputs.hasChange == 'true' }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
- name: Setup Pages
if: ${{ steps.commit-files.outputs.hasChange == 'true' }}
uses: actions/configure-pages@v5
- name: Upload artifact
if: ${{ steps.commit-files.outputs.hasChange == 'true' }}
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: '.'
- name: Deploy to GitHub Pages
if: ${{ steps.commit-files.outputs.hasChange == 'true' }}
id: deployment
uses: actions/deploy-pages@v4