Sync and Replace #3176
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 and Replace | |
on: | |
schedule: | |
- cron: '*/30 * * * *' # 每30分钟检查一次更新 | |
workflow_dispatch: # 允许手动触发 | |
jobs: | |
sync-and-replace: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout B repo | |
uses: actions/checkout@v2 | |
with: | |
repository: 'minseks/Beijing-IPTV' | |
token: ${{ secrets.GITHUB_TOKEN }} | |
fetch-depth: 0 # 获取所有历史以便于比较 | |
- name: Pull updates from A repo | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git remote add upstream https://github.com/qwerttvv/Beijing-IPTV.git | |
git fetch upstream | |
git checkout master # 或者你的默认分支名,比如master | |
git checkout upstream/master -- IPTV-Unicom.m3u | |
- name: Replace URLs in IPTV-Unicom.m3u | |
run: | | |
sed -i 's|http://192.168.123.1:23234|http://192.168.31.104:4022|g' IPTV-Unicom.m3u | |
git add IPTV-Unicom.m3u | |
- name: Check for changes | |
id: check_changes | |
run: | | |
if git diff --quiet -- IPTV-Unicom.m3u; then | |
echo "CHANGES_FOUND=false" >> $GITHUB_ENV | |
else | |
echo "CHANGES_FOUND=true" >> $GITHUB_ENV | |
fi | |
- name: Commit and push changes | |
if: env.CHANGES_FOUND == 'true' | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add IPTV-Unicom.m3u | |
git commit -m "Sync A and update URLs" | |
git push |