Skip to content

Life recent auto update #475

Life recent auto update

Life recent auto update #475

name: Life recent auto update
on:
# push:
# branches:
# - master
# paths:
# - "life/**"
# - "!life/.vitepress/**"
# - "!life/*"
# - ".github/workflows/life-recent-update.yml"
# - "script/requirements.txt"
# # paths-ignore:
# # - "life/.vitepress/**"
# pull_request:
# types: [opened, synchronize]
# branches:
# - master
# paths:
# - "life/**"
# - "!life/.vitepress/**"
# - "!life/*"
# - ".github/workflows/life-recent-update.yml"
# - "script/requirements.txt"
schedule:
# This is run at UTC 16:00 p.m., aka UTC+8 0:00 a.m. Only Sunday
- cron: "0 16 * * 0"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: write
jobs:
py-life-recent:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./script
steps:
- name: Checkout repository content
uses: actions/checkout@v4
# https://github.com/actions/checkout?tab=readme-ov-file#fetch-all-history-for-all-tags-and-branches
# Fetch all history for all tags and branches
# for py script
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Execute Python script
run: |
python latest.py 1
- name: Commit files
id: commit
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
if git diff --cached --quiet; then
echo "No changes to commit"
echo "has_changes=false" >> $GITHUB_OUTPUT
else
git commit -m "docs: life latest" -a
echo "has_changes=true" >> $GITHUB_OUTPUT
fi
- name: test output
env:
AUGAGU: ${{steps.commit.outputs.has_changes}}
run: |
echo "=========="
echo "$GITHUB_OUTPUT"
echo "=========="
echo "${{steps.commit.outputs.has_changes}}"
echo "=========="
echo "$AUGAGU"
# 还有更好的操作,直接推送。而后在凌晨1点自动构建,免得 pr 了
- name: Push changes
if: steps.commit.outputs.has_changes == 'true' && github.event_name != 'pull_request'
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.DEPLOY_GH }}
# https://github.com/orgs/community/discussions/150767#discussioncomment-12072008
# head_ref / ref_name
# branch: ${{ github.ref_name }}
# - name: Create Pull Request
# if: ${{ steps.commit.outputs.has_changes == 'true' }}
# uses: peter-evans/create-pull-request@v7
# with:
# token: ${{ secrets.DEPLOY_GH }}
# title: "docs: life latest"
# commit-message: "docs: life latest"
# committer: GitHub <noreply@github.com>
# author: GitHub <noreply@github.com>
# branch: create-pull-request/patch-life-recent-update
# base: master
# labels: |
# report
# automated pr
# assignees: DrAugus
# # Review cannot be requested from pull request author.
# # reviewers: DrAugus