-
Notifications
You must be signed in to change notification settings - Fork 1
68 lines (60 loc) · 2.24 KB
/
Copy pathsource-freshness.yml
File metadata and controls
68 lines (60 loc) · 2.24 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
name: Source freshness
on:
schedule:
- cron: "17 6 * * 1"
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
check:
name: Check canonical upstream sources
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: "3.12"
cache: pip
- name: Install runtime dependencies
run: python -m pip install -r requirements.txt
- name: Compare declared snapshots with upstream artifacts
run: >-
python scripts/update_sources.py
--check
--report "${RUNNER_TEMP}/source-freshness.json"
- name: Preserve freshness evidence
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: source-freshness
path: ${{ runner.temp }}/source-freshness.json
retention-days: 30
- name: Open one tracking issue when an update is available
env:
GH_TOKEN: ${{ github.token }}
REPORT: ${{ runner.temp }}/source-freshness.json
run: |
updates="$(python -c 'import json, os; print(", ".join(json.load(open(os.environ["REPORT"]))["updates_available"]))')"
if [ -z "${updates}" ]; then
exit 0
fi
existing="$(
gh issue list \
--repo "${GITHUB_REPOSITORY}" \
--state open \
--search '"Upstream source update available" in:title' \
--json number \
--jq 'length'
)"
if [ "${existing}" -eq 0 ]; then
gh issue create \
--repo "${GITHUB_REPOSITORY}" \
--title "Upstream source update available" \
--label "source-update" \
--body "The scheduled freshness check detected changes for: ${updates}. Review the workflow artifact and use scripts/update_sources.py to stage a dated snapshot. No source or generated dataset was modified automatically."
fi