Skip to content

Life recent auto update #454

Life recent auto update

Life recent auto update #454

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.
- cron: "0 16 * * *"
# 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"
- 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@v6
# 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
deploy-life:
needs: py-life-recent
strategy:
matrix:
os: [ubuntu-latest] # macos-latest, windows-latest
deploy-dir: [life/.vitepress/dist]
deploy-user: [augusmeow]
deploy-repo: [life, augusmeow.github.io]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
# “最近更新时间” 等 git 日志相关信息,需要拉取全部提交记录
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- uses: pnpm/action-setup@v4.1.0
name: Install pnpm
id: pnpm-install
with:
version: 7
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Change config
run: mv ./life/.vitepress/config.ts.replace ./life/.vitepress/config.ts
if: ${{ matrix.deploy-repo == 'life' }}
# 运行构建脚本
- name: Build VitePress site
env:
NODE_OPTIONS: --max_old_space_size=4096
run: pnpm life:build
- name: Add google
run: |
echo "google-site-verification: googlea936c3462e7f8864.html" >> ./life/.vitepress/dist/googlea936c3462e7f8864.html
if: ${{ matrix.deploy-repo == 'augusmeow.github.io' }}
- name: Deploy to GitHub Pages
uses: crazy-max/ghaction-github-pages@v4.1.0
with:
repo: ${{ matrix.deploy-user }}/${{ matrix.deploy-repo }}
target_branch: gh-pages
build_dir: ${{ matrix.deploy-dir }}
jekyll: false
env:
GH_PAT: ${{ secrets.DEPLOY_GH }}