Skip to content

sync: check sources and update #36

sync: check sources and update

sync: check sources and update #36

Workflow file for this run

name: "sync: check sources and update"
on:
schedule:
- cron: "0 0 2 * *"
workflow_dispatch:
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
concurrency:
group: sync-files
cancel-in-progress: true
jobs:
sync_files:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: write
steps:
- name: "chore: checkout repository"
uses: actions/checkout@v5
- name: "sync: update mpv scripts"
run: |
sync_file() {
local url="$1"
local dest="$2"
local tmp
tmp="$(mktemp)"
HTTP_CODE=$(curl -sS -f --retry 3 --retry-delay 5 -w "%{http_code}" -o "$tmp" "$url" || echo "000")
if [ "$HTTP_CODE" != "200" ]; then
echo "Failed to download $dest (HTTP code $HTTP_CODE)"
rm -f "$tmp"
return
fi
if ! cmp -s "$tmp" "$dest"; then
mv "$tmp" "$dest"
echo "Updated $dest"
else
rm -f "$tmp"
echo "$(basename "$dest") is up-to-date"
fi
}
sync_file \
"https://codeberg.org/jouni/mpv_sponsorblock_minimal/raw/branch/master/sponsorblock_minimal.lua" \
"scripts/sponsorblock_minimal.lua"
sync_file \
"https://raw.githubusercontent.com/po5/thumbfast/master/thumbfast.lua" \
"scripts/thumbfast.lua"
- name: "chore: commit and push changes"
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "GitHub Actions"
if ! git diff --quiet; then
git add .
git commit -m "sync: update scripts"
git push
else
echo "No changes to commit"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}