更新订阅 #33176
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: 更新订阅 | |
on: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '*/10 * * * *' | |
jobs: | |
run-main: | |
runs-on: ubuntu-latest | |
steps: | |
- name: 检出仓库代码 | |
uses: actions/checkout@master | |
- name: run update subs | |
run: | | |
rm -f v2.txt | |
rm -rf ./r2 | |
cp main main_tmp | |
chmod +x main_tmp | |
./main_tmp cfg.json | |
rm main_tmp | |
- name: Check for local changes | |
uses: actions/github-script@v5 | |
with: | |
script: | | |
const { execSync } = require('child_process'); | |
// Check for local changes | |
const output = execSync('git status --porcelain'); | |
if (output.toString().trim() === '') { | |
console.log('No local changes detected. Cancelling workflow.'); | |
process.exit(78); // Exit with a neutral status code to cancel the workflow | |
} else { | |
console.log('Local changes detected. Workflow will continue.'); | |
} | |
# - uses: actions/checkout@v2 | |
- name: Commit Changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.email "46045921+hellowzsg@users.noreply.github.com" | |
git config --global user.name "wakk" | |
git status | |
git add ./out | |
git commit -m "update sub" | |
git push | |
- name: prepare r2 dir | |
run: | | |
mkdir r2 | |
cp -r ./out/* ./r2 | |
for file in "$(pwd)"/r2/*; do | |
if [ -f "$file" ]; then | |
# 将文件内容进行 Base64 编码 | |
base64 -w 0 "$file" > temp.txt && mv temp.txt "$file" && cat "$file" && echo | |
fi | |
done | |
# cf r2 put object | |
- uses: ryand56/r2-upload-action@latest | |
name: put object cf R2 | |
with: | |
r2-account-id: ${{ secrets.R2_ACCOUNT_ID }} | |
r2-access-key-id: ${{ secrets.R2_ACCESS_KEY_ID }} | |
r2-secret-access-key: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
r2-bucket: ${{ secrets.R2_BUCKET }} | |
source-dir: ./r2 | |
destination-dir: ./ |