Sync pictures #83
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: Sync pictures | |
on: | |
schedule: | |
- cron: '0 22 * * *' | |
workflow_dispatch: | |
permissions: | |
contents: write | |
deployments: write | |
jobs: | |
Sync: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 检出仓库 | |
uses: actions/checkout@v4 | |
- name: 从源仓库 Clone | |
run: | | |
git config --global user.email "action@github.com" | |
git config --global user.name "GitHub Action" | |
git clone https://github.com/WorldHim/PCL2Hub.git | |
- name: 操作文件 | |
run: | | |
cd PCL2Hub | |
rm -rf httpcat | |
rm -rf http | |
rm -rf vlog | |
cd .. | |
rm -rf meme | |
- name: 运行查重脚本 | |
run: | | |
python Move.py | |
- name: 删除无用的临时文件 | |
run: | | |
rm -rf PCL2Hub | |
- 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 }} | |