Daily Job #163
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' | |
on: | |
schedule: | |
- cron: '0 0 * * *' # 每天UTC时间00:00运行 | |
workflow_dispatch: | |
inputs: | |
environment: | |
description: 'Environment to deploy to' | |
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 | |
- name: Run Python script | |
run: python main.py | |
- name: Upload generated files | |
uses: actions/upload-artifact@v4 | |
with: | |
name: generated-files | |
path: | | |
merged_output.txt | |
others_output.txt | |
- name: Commit changes | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
git add merged_output.txt | |
git add merged_output.m3u | |
git add others_output.txt | |
git commit -m ":tada: AutoUpdate $(date +'%Y%m%d')" | |
current_datetime=$(date +"%Y%m%d_%H%M%S") | |
cp merged_output.txt history/"${current_datetime}_merged_output.txt" | |
cp others_output.txt history/"${current_datetime}_others_output.txt" | |
git add history/"${current_datetime}_merged_output.txt" | |
git add history/"${current_datetime}_others_output.txt" | |
git commit -m "Archive file with timestamp" | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |