Merge pull request #318 from ch-bas/fix/frigate-detect-substream #33
This file contains hidden or 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: archive-sources | |
| # Datasheet preservation (CI idea #3). On every push to main that touches a | |
| # camera file, submit that camera's source URLs to the Internet Archive's | |
| # Wayback "Save Page Now" API, so a permanent snapshot survives manufacturer | |
| # link-rot. Scoped to CHANGED cameras so we only archive what's new. | |
| # | |
| # Advisory only: Wayback rate-limits / downtime never fail the workflow. | |
| # Manual runs can re-archive a whole brand or the entire catalogue. | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - "cameras/**" | |
| schedule: | |
| - cron: "0 3 5 * *" # 5th of each month, 03:00 UTC — full-catalogue sweep | |
| workflow_dispatch: | |
| inputs: | |
| scope: | |
| description: "Scope: 'changed' (default), a brand name (e.g. hikvision), or 'all'" | |
| required: false | |
| default: "changed" | |
| permissions: | |
| contents: read | |
| # One run at a time — keeps us well under Wayback's rate limits. | |
| concurrency: | |
| group: archive-sources | |
| cancel-in-progress: false | |
| jobs: | |
| archive: | |
| runs-on: ubuntu-latest | |
| # Long timeout for the monthly `all` sweep; per-push runs finish in minutes. | |
| # Re-runs are cheap because already-archived URLs are skipped (ARCHIVE_SKIP_DAYS). | |
| timeout-minutes: 350 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # need history to diff the pushed range | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| # No `npm ci` — scripts/archive-sources.js only uses Node built-ins + fetch. | |
| - name: Archive source URLs to the Wayback Machine | |
| run: | | |
| # Resolve scope: scheduled run = full sweep; dispatch = input; push = changed. | |
| scope="${{ github.event.inputs.scope }}" | |
| if [ "${{ github.event_name }}" = "schedule" ]; then scope="all"; fi | |
| if [ -z "$scope" ]; then scope="changed"; fi | |
| if [ "$scope" = "all" ]; then | |
| node scripts/archive-sources.js --all | |
| elif [ "$scope" != "changed" ] && [ -n "$scope" ]; then | |
| node scripts/archive-sources.js --brand "$scope" | |
| else | |
| base='${{ github.event.before }}' | |
| if [ -z "$base" ] || [ "$base" = "0000000000000000000000000000000000000000" ]; then | |
| base="HEAD~1" | |
| fi | |
| files=$(git diff --name-only "$base" "${{ github.sha }}" -- 'cameras/**/*.json' 2>/dev/null || true) | |
| if [ -z "$files" ]; then | |
| echo "No changed camera files in this push — nothing to archive." | |
| exit 0 | |
| fi | |
| echo "Changed camera files:"; echo "$files" | |
| node scripts/archive-sources.js $files | |
| fi |