CronJob #15426
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: CronJob | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "0 12 * * *" | |
jobs: | |
RunCronJob: | |
name: CheckAndPush | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup Python3 environment | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Fetch latest data | |
env: | |
URI: ${{ vars.URI }} | |
KEYWORD: ${{ vars.KEYWORD }} | |
run: bash ./cronjob.sh | |
- name: Commit files | |
id: commit-files | |
run: | | |
if [ -n "$(git status --porcelain data.html)" ]; then | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
git add data.html | |
git commit -m "action: update data" | |
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: Send mail | |
uses: dawidd6/action-send-mail@master | |
if: ${{ steps.commit-files.outputs.hasChange == 'true' }} | |
with: | |
server_address: smtp.qq.com | |
server_port: 465 | |
username: ${{ secrets.QQEMAIL_USERNAME }} | |
password: ${{ secrets.QQEMAIL_TOKEN }} | |
subject: 'OpenKikCoc: cronjob-ziroom' | |
html_body: file://data.html | |
to: ${{ secrets.QQEMAIL_USERNAME }} | |
from: GitHub Actions |