-
Notifications
You must be signed in to change notification settings - Fork 0
61 lines (51 loc) · 2 KB
/
Copy pathclimate-update.yml
File metadata and controls
61 lines (51 loc) · 2 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
name: Monthly Climate Data Update
on:
schedule:
- cron: '0 6 1 * *' # 1st of each month, 6am UTC
workflow_dispatch: # manual trigger
jobs:
update:
runs-on: ubuntu-latest
timeout-minutes: 360 # 6 hours max
env:
EDH_TOKEN: ${{ secrets.EDH_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: us-west-2
steps:
- uses: actions/checkout@v4
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true
- uses: r-lib/actions/setup-r-dependencies@v2
- name: Install uv (runs the Python backfill)
uses: astral-sh/setup-uv@v5
- name: Verify required secrets present
run: |
missing=()
[ -z "$EDH_TOKEN" ] && missing+=("EDH_TOKEN")
[ -z "$AWS_ACCESS_KEY_ID" ] && missing+=("AWS_ACCESS_KEY_ID")
[ -z "$AWS_SECRET_ACCESS_KEY" ] && missing+=("AWS_SECRET_ACCESS_KEY")
if [ ${#missing[@]} -gt 0 ]; then
echo "ERROR: missing secrets: ${missing[*]}"
exit 1
fi
- name: Run EDH update pipeline
# pipefail so Rscript's exit code propagates through `tee`; default
# bash -e alone would let tee swallow a non-zero R exit.
shell: bash
run: |
set -o pipefail
mkdir -p logs
Rscript scripts/pipeline_update_edh.R 2>&1 | tee logs/update_$(date +%Y%m%d).log
# Only commit logs when running on main. workflow_dispatch from a
# feature branch should not rebase onto or push to main.
- name: Commit log
if: always() && github.ref == 'refs/heads/main'
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git pull --rebase origin main
git add logs/ || true
git diff --cached --quiet || git commit -m "Monthly climate update $(date +%Y-%m-%d)"
git push