Photon Data Monitor #27
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: Photon Data Monitor | |
| on: | |
| schedule: | |
| - cron: '22 8 * * *' | |
| workflow_dispatch: # Allow manual triggering | |
| jobs: | |
| check-data-freshness: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Check Photon import date | |
| id: check | |
| run: | | |
| INFO=$(curl -sf https://geocoder-proxy.entur.io/info) | |
| IMPORT_DATE=$(echo "$INFO" | jq -r '.photonImportDate') | |
| echo "Import date: $IMPORT_DATE" | |
| if [ "$IMPORT_DATE" = "null" ] || [ "$IMPORT_DATE" = "unknown" ]; then | |
| echo "alert=true" >> "$GITHUB_OUTPUT" | |
| echo "message=⚠️ Photon data import date is unavailable" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| # Parse the import date (ISO 8601 with milliseconds: 2025-12-01T08:38:18.728Z) | |
| IMPORT_TIMESTAMP=$(date -u -d "$IMPORT_DATE" +%s 2>/dev/null) | |
| if [ -z "$IMPORT_TIMESTAMP" ]; then | |
| echo "alert=true" >> "$GITHUB_OUTPUT" | |
| echo "message=⚠️ Unable to parse Photon import date: $IMPORT_DATE" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| CURRENT_TIMESTAMP=$(date -u +%s) | |
| AGE_SECONDS=$(( CURRENT_TIMESTAMP - IMPORT_TIMESTAMP )) | |
| AGE_HOURS=$(( AGE_SECONDS / 3600 )) | |
| AGE_MINUTES=$(( (AGE_SECONDS % 3600) / 60 )) | |
| echo "Data age: ${AGE_HOURS}h ${AGE_MINUTES}m" | |
| if [ $AGE_HOURS -gt 50 ]; then | |
| echo "alert=true" >> "$GITHUB_OUTPUT" | |
| echo "message=⚠️ Photon data is ${AGE_HOURS}h ${AGE_MINUTES}m old (last import: $IMPORT_DATE)" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "alert=false" >> "$GITHUB_OUTPUT" | |
| echo "message=Data is fresh (${AGE_HOURS}h ${AGE_MINUTES}m old)" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Send Slack notification | |
| if: steps.check.outputs.alert == 'true' | |
| uses: slackapi/slack-github-action@v2 | |
| with: | |
| webhook: ${{ secrets.SLACK_WEBHOOK_URL }} | |
| webhook-type: incoming-webhook | |
| payload: | | |
| text: "${{ steps.check.outputs.message }} | <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|run>" | |
| - name: Summary | |
| run: | | |
| echo "alert=${{ steps.check.outputs.alert }}" >> "$GITHUB_STEP_SUMMARY" | |
| echo "${{ steps.check.outputs.message }}" >> "$GITHUB_STEP_SUMMARY" |