Daily Invader Spotter Sync #41
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: Daily Invader Spotter Sync | |
| on: | |
| schedule: | |
| - cron: "0 5 * * *" | |
| workflow_dispatch: | |
| inputs: | |
| test_notification: | |
| description: "Run a notification-only test instead of the full sync" | |
| required: false | |
| type: boolean | |
| default: false | |
| ntfy_url: | |
| description: "Override ntfy endpoint for this run" | |
| required: false | |
| default: "" | |
| ntfy_token: | |
| description: "Override ntfy token for this run" | |
| required: false | |
| default: "" | |
| permissions: | |
| contents: write | |
| jobs: | |
| sync-and-upload: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 120 | |
| container: | |
| image: "mcr.microsoft.com/playwright:v1.58.2-noble" | |
| defaults: | |
| run: | |
| shell: bash | |
| env: | |
| SI_REFERENCE_LIBRARY: ${{ github.workspace }} | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| NTFY_URL: ${{ github.event.inputs.ntfy_url || secrets.NTFY_URL }} | |
| NTFY_TOKEN: ${{ github.event.inputs.ntfy_token || secrets.NTFY_TOKEN }} | |
| PLAYWRIGHT_BROWSERS_PATH: /ms-playwright | |
| PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" | |
| steps: | |
| - name: Checkout reference library | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| cache: npm | |
| - name: Validate image wall repo token | |
| if: ${{ github.event.inputs.test_notification != 'true' }} | |
| env: | |
| SI_IMAGE_WALL_REPO_TOKEN: ${{ secrets.SI_IMAGE_WALL_REPO_TOKEN }} | |
| run: | | |
| if [ -z "$SI_IMAGE_WALL_REPO_TOKEN" ]; then | |
| echo 'SI_IMAGE_WALL_REPO_TOKEN is empty or unset.' | |
| exit 1 | |
| fi | |
| git -c "http.https://github.com/.extraheader=" ls-remote "https://x-access-token:${SI_IMAGE_WALL_REPO_TOKEN}@github.com/jfix/si-image-wall.git" | |
| - name: Clone image wall repo | |
| if: ${{ github.event.inputs.test_notification != 'true' }} | |
| env: | |
| SI_IMAGE_WALL_REPO_TOKEN: ${{ secrets.SI_IMAGE_WALL_REPO_TOKEN }} | |
| run: | | |
| git -c "http.https://github.com/.extraheader=" clone --depth 1 --branch main "https://x-access-token:${SI_IMAGE_WALL_REPO_TOKEN}@github.com/jfix/si-image-wall.git" si-image-wall | |
| - name: Install reference-library dependencies | |
| run: npm ci | |
| - name: Discover new mosaics | |
| if: ${{ github.event.inputs.test_notification != 'true' }} | |
| timeout-minutes: 30 | |
| run: node scripts/daily-new-mosaics.mjs --report-path tmp/daily-new-mosaics-report.json | |
| - name: Prepare notification test report | |
| if: ${{ github.event.inputs.test_notification == 'true' }} | |
| run: | | |
| mkdir -p tmp | |
| cat > tmp/daily-new-mosaics-report.json <<'JSON' | |
| { | |
| "new_invaders": [ | |
| { | |
| "code": "TEST", | |
| "city": "Test City", | |
| "invader_id": "TEST_001" | |
| } | |
| ] | |
| } | |
| JSON | |
| - name: Install image-wall dependencies | |
| if: ${{ github.event.inputs.test_notification != 'true' }} | |
| working-directory: si-image-wall | |
| run: npm ci | |
| - name: Validate Cloudflare credentials | |
| if: ${{ github.event.inputs.test_notification != 'true' }} | |
| run: | | |
| if [ -z "$CLOUDFLARE_API_TOKEN" ]; then | |
| echo 'CLOUDFLARE_API_TOKEN is empty or unset.' | |
| exit 1 | |
| fi | |
| if [ -z "$CLOUDFLARE_ACCOUNT_ID" ]; then | |
| echo 'CLOUDFLARE_ACCOUNT_ID is empty or unset.' | |
| exit 1 | |
| fi | |
| - name: Upload new grosplan images to R2 | |
| if: ${{ github.event.inputs.test_notification != 'true' }} | |
| run: | | |
| set -o pipefail | |
| node si-image-wall/scripts/upload-ref-images.mjs --manifest tmp/daily-new-mosaics-report.json --skip-existing 2>&1 | tee tmp/upload-ref-images.log | |
| if grep -q '^FAIL ' tmp/upload-ref-images.log; then | |
| echo 'Detected one or more failed image uploads.' | |
| exit 1 | |
| fi | |
| - name: Catch-up upload any ref images missing from R2 | |
| if: ${{ github.event.inputs.test_notification != 'true' }} | |
| run: | | |
| set -o pipefail | |
| node si-image-wall/scripts/upload-ref-images.mjs --skip-existing 2>&1 | tee tmp/upload-ref-images-catchup.log | |
| if grep -q '^FAIL ' tmp/upload-ref-images-catchup.log; then | |
| echo 'Detected one or more failed catch-up image uploads.' | |
| exit 1 | |
| fi | |
| - name: Commit new reference-library changes | |
| if: ${{ github.event.inputs.test_notification != 'true' }} | |
| run: | | |
| if git diff --quiet -- references data/cities.json; then | |
| echo 'No reference-library changes to commit.' | |
| exit 0 | |
| fi | |
| git add references data/cities.json | |
| git -c user.name='github-actions[bot]' -c user.email='github-actions[bot]@users.noreply.github.com' commit -m 'chore: persist daily invader-spotter refs' | |
| git push origin HEAD:${{ github.ref_name }} | |
| - name: Send ntfy notification | |
| continue-on-error: true | |
| run: node scripts/send-ntfy.mjs --report-path tmp/daily-new-mosaics-report.json |