Repository navigation
107 lines (95 loc) · 3.9 KB
/
Copy pathrefresh-external.yml
File metadata and controls
107 lines (95 loc) · 3.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# Weekly refresh of the public environmental snapshots in external/ (#22): weather, waves,
# SST, Coral Reef Watch heat stress, Papeete tides, ENSO indices, IBTrACS cyclone tracks and school
# holidays. When anything changed,
# commit it to main, cut a patch release and publish the image so servers pick up fresh data.
# No spreadsheet data is involved.
name: Refresh environmental data
on:
schedule:
- cron: '40 15 * * 1' # Mondays ~01:40 AEST
workflow_dispatch:
concurrency:
group: refresh-external-${{ github.repository }}
cancel-in-progress: false
permissions:
contents: write
packages: write
jobs:
refresh:
runs-on: ubuntu-latest
# A full run took 48 minutes on 4 Nov 2026 with NOAA ERDDAP stalls and 429 backoff possible on top.
timeout-minutes: 120
outputs:
version: ${{ steps.version.outputs.version }}
changed: ${{ steps.diff.outputs.changed }}
fetch-outcome: ${{ steps.fetch.outcome }}
steps:
- uses: actions/checkout@v7
with:
ref: main
- uses: actions/setup-node@v7
with:
node-version: 26
- name: Fetch snapshots
id: fetch
continue-on-error: true
run: node scripts/fetch-external.mjs
- name: Detect changes
id: diff
run: |
if git diff --quiet -- external; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "No new environmental data."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
git diff --stat -- external
fi
- name: Bump patch version
if: steps.diff.outputs.changed == 'true'
id: version
run: |
NEW_VERSION="$(npm version patch --no-git-tag-version)"
echo "version=${NEW_VERSION#v}" >> "$GITHUB_OUTPUT"
- name: Commit, tag and release
if: steps.diff.outputs.changed == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ steps.version.outputs.version }}
FETCH_OUTCOME: ${{ steps.fetch.outcome }}
RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add external package.json
# Name what changed: after a partial refresh, not every source was updated (#159).
FILES="$(git diff --cached --name-only -- external | sed 's#^external/##' | paste -sd, - | sed 's/,/, /g')"
NOTES="Weekly refresh of the environmental snapshots. Updated: ${FILES}."
if [ "$FETCH_OUTCOME" = "failure" ]; then
NOTES="${NOTES} Some sources failed and kept their previous snapshot; see ${RUN_URL}."
fi
git commit -m "chore(data): weekly environmental data refresh (v${VERSION})"
git pull --rebase origin main
git tag "v${VERSION}"
git push origin HEAD:main "v${VERSION}"
gh release create "v${VERSION}" --target main --title "v${VERSION}" --notes "$NOTES"
docker:
needs: refresh
if: needs.refresh.outputs.changed == 'true'
uses: ./.github/workflows/docker-release.yml
permissions:
contents: read
packages: write
with:
ref: v${{ needs.refresh.outputs.version }}
# Wait for the release/image before surfacing partial failure. Otherwise a failed
# refresh dependency would skip Docker and leave successful snapshots undeployed.
report:
needs: [refresh, docker]
if: always() && needs.refresh.outputs.fetch-outcome == 'failure'
runs-on: ubuntu-latest
steps:
- name: Report source failures
run: |
echo "::error::Some environmental sources failed. See the refresh job summary and fetch log. Successful snapshots were eligible for release; failed sources retained their previous snapshots."
exit 1