Skip to content

Monitor Snapshot Updates #5

Monitor Snapshot Updates

Monitor Snapshot Updates #5

Workflow file for this run

name: Monitor Snapshot Updates
on:
schedule:
- cron: '0 * * * *' # 每小时运行一次
workflow_dispatch:
jobs:
monitor:
runs-on: ubuntu-latest
steps:
- name: Fetch current snapshot files
run: |
URL="https://downloads.immortalwrt.org/snapshots/targets/x86/64/"
curl -s $URL > $RUNNER_TEMP/current_snapshot.html
- name: Compare with previous snapshot
run: |
LAST_SNAPSHOT="$RUNNER_TEMP/last_snapshot.html"
CURRENT_SNAPSHOT="$RUNNER_TEMP/current_snapshot.html"
# 如果之前没有保存快照,初始化空文件
if [ ! -f "$LAST_SNAPSHOT" ]; then
echo "首次运行,创建初始快照文件。"
touch "$LAST_SNAPSHOT"
fi
# 对比快照文件
if ! cmp -s "$CURRENT_SNAPSHOT" "$LAST_SNAPSHOT"; then
echo "检测到更新!"
echo "updated=true" >> $GITHUB_ENV
else
echo "没有检测到更新。"
echo "updated=false" >> $GITHUB_ENV
fi
- name: Save the latest snapshot
if: env.updated == 'true'
run: |
mv $RUNNER_TEMP/current_snapshot.html $RUNNER_TEMP/last_snapshot.html