Daily Job(urlSnapshot) #8
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: 'Daily Job(urlSnapshot)' | |
on: | |
schedule: | |
- cron: '00 4 * * 0' # 每周日 4:00 (UTC) 执行 | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Daily Job(urlSnapshot)' | |
required: true | |
default: 'production' | |
jobs: | |
run_job: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests | |
- name: Run Python script | |
run: python assets/snapshot/snapshot.py | |
- name: Commit changes | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
# 将归档文件打包zip文件 | |
current_date=$(date +%Y-%m-%d) | |
current_datetime=$(date +"%Y%m%d_%H%M") | |
zip_filename="${current_datetime}_UrlSnapshot.zip" | |
zip -r "assets/snapshot/${zip_filename}" "assets/snapshot/${current_date}" | |
git add "assets/snapshot/${zip_filename}" | |
git commit -m "(UrlSnapshot) archive snapshot file" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |