Skip to content

Sync pictures

Sync pictures #25

name: Sync pictures
on:
schedule:
- cron: '0 22 * * *'
workflow_dispatch:
permissions:
contents: write
deployments: write
jobs:
Sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Clone from origin repo
run: |
git config --global user.email "action@github.com"
git config --global user.name "GitHub Action"
git clone https://github.com/PCL-Community/worldhim-alist-backup.git
- name: Get files
run: |
cd worldhim-alist-backup
rm -rf randpic/httpcat
rm -rf randpic/http
rm -rf randpic/vlog
mv randpic ..
cd ..
rm -rf worldhim-alist-backup
rm -rf meme
- name: Run script
run: |
python sync.py
- name: Delete temp files
run: |
rm -rf randpic
- name: 提交更改
# codes from: https://github.com/PCL-Community/PCL2Help-Backup/blob/main/.github/workflows/sync.yml
id: check_commit
run: |
# 检查是否有文件被修改但尚未提交
if [[ $(git status --porcelain) ]]; then
echo "有文件被修改但尚未提交。"
# 输出修改的文件列表
git status --short
# 添加所有已修改的文件到暂存区
git add .
# 提交暂存区中的文件到仓库
git config --local user.email "action@github.com"
git config --local user.name "Github Action"
git commit -m "Sync"
echo "文件已提交到仓库。"
echo "::set-output name=commit_required::true"
else
echo "没有文件被修改。"
echo "::set-output name=commit_required::false"
fi
- name: 推送更改
# codes from: https://github.com/PCL-Community/PCL2Help-Backup/blob/main/.github/workflows/sync.yml
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
generate-config-file:
name: Generate config file
runs-on: ubuntu-latest
needs: Sync
permissions:
contents: write
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: build config
run: |
./shell/computed.sh
cat static/scripts/config.js
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'chore: update config file'
file_pattern: static/scripts/config.js
env:
GITHUB_TOKEN: ${{ secrets.SHEEP }}