|
23 | 23 | required: false |
24 | 24 | default: "50" |
25 | 25 | type: string |
| 26 | + period_start: |
| 27 | + description: "Manual weekly period Monday UTC (YYYY-MM-DD)." |
| 28 | + required: true |
| 29 | + type: string |
| 30 | + as_of: |
| 31 | + description: "Manual weekly as_of Sunday UTC (YYYY-MM-DD)." |
| 32 | + required: true |
| 33 | + type: string |
26 | 34 | commit_outputs: |
27 | 35 | description: "Commit generated live CSV outputs back to data/live." |
28 | 36 | required: false |
|
32 | 40 | - "false" |
33 | 41 | - "true" |
34 | 42 | schedule: |
35 | | - - cron: "15 12 * * 6" |
| 43 | + - cron: "15 0 * * 1" |
36 | 44 |
|
37 | 45 | permissions: |
38 | 46 | contents: write |
|
46 | 54 | runs-on: ubuntu-latest |
47 | 55 | timeout-minutes: 30 |
48 | 56 | steps: |
49 | | - - uses: actions/checkout@v6 |
50 | | - - uses: actions/setup-python@v6 |
| 57 | + - uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6 |
| 58 | + - uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6 |
51 | 59 | with: |
52 | 60 | python-version: "3.11" |
53 | 61 | - name: Install package |
|
75 | 83 | --watchlist "${WATCHLIST_PATH}" \ |
76 | 84 | --events data/output/rss_source_pipeline/source_events.csv \ |
77 | 85 | --output data/output/rss_source_pipeline/source_tracker.csv |
| 86 | + - name: Build weekly contract artifact |
| 87 | + env: |
| 88 | + INPUT_PERIOD_START: ${{ inputs.period_start || '' }} |
| 89 | + INPUT_AS_OF: ${{ inputs.as_of || '' }} |
| 90 | + PRODUCER_REF: ${{ github.sha }} |
| 91 | + run: | |
| 92 | + set -euo pipefail |
| 93 | + if [ "${GITHUB_EVENT_NAME}" = "workflow_dispatch" ]; then |
| 94 | + test -n "${INPUT_PERIOD_START}" |
| 95 | + test -n "${INPUT_AS_OF}" |
| 96 | + PERIOD_START="${INPUT_PERIOD_START}" |
| 97 | + AS_OF="${INPUT_AS_OF}" |
| 98 | + RUN_MODE=manual |
| 99 | + else |
| 100 | + RUN_DATE="$(date -u +%F)" |
| 101 | + read -r PERIOD_START AS_OF < <(RUN_DATE="${RUN_DATE}" python3 - <<'PY' |
| 102 | + import os |
| 103 | + from datetime import date, timedelta |
| 104 | +
|
| 105 | + today = date.fromisoformat(os.environ["RUN_DATE"]) |
| 106 | + start = today - timedelta(days=today.weekday() + 7) |
| 107 | + print(start.isoformat(), (start + timedelta(days=6)).isoformat()) |
| 108 | + PY |
| 109 | + ) |
| 110 | + RUN_MODE=scheduled |
| 111 | + fi |
| 112 | + GENERATED_AT="$(date -u +%Y-%m-%dT%H:%M:%S.%6NZ)" |
| 113 | + python scripts/write_weekly_artifact.py \ |
| 114 | + --base-dir . \ |
| 115 | + --output-dir data/output/rss_source_pipeline/weekly-artifact \ |
| 116 | + --feed-status data/output/rss_source_pipeline/source_fetch_status.json \ |
| 117 | + --period-start "${PERIOD_START}" \ |
| 118 | + --as-of "${AS_OF}" \ |
| 119 | + --generated-at "${GENERATED_AT}" \ |
| 120 | + --run-mode "${RUN_MODE}" \ |
| 121 | + --producer-ref "${PRODUCER_REF}" \ |
| 122 | + --source-provenance official_political_event_tracking_research_v1 \ |
| 123 | + data/output/rss_source_pipeline/source_items.csv \ |
| 124 | + data/output/rss_source_pipeline/source_events.csv \ |
| 125 | + data/output/rss_source_pipeline/source_tracker.csv \ |
| 126 | + data/output/rss_source_pipeline/source_fetch_status.json |
78 | 127 | - name: Publish live CSV outputs to repository |
79 | 128 | env: |
80 | 129 | COMMIT_OUTPUTS: ${{ github.event_name == 'schedule' && 'true' || github.event.inputs.commit_outputs || 'false' }} |
@@ -108,8 +157,15 @@ jobs: |
108 | 157 | git push |
109 | 158 | fi |
110 | 159 | - name: Upload RSS source artifact |
111 | | - uses: actions/upload-artifact@v7 |
| 160 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 |
112 | 161 | with: |
113 | 162 | name: rss-source-pipeline |
114 | 163 | path: data/output/rss_source_pipeline/ |
115 | 164 | if-no-files-found: error |
| 165 | + - name: Upload weekly contract artifact |
| 166 | + uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7 |
| 167 | + with: |
| 168 | + name: political-event-weekly-v1 |
| 169 | + path: data/output/rss_source_pipeline/weekly-artifact/weekly_manifest.json |
| 170 | + if-no-files-found: error |
| 171 | + retention-days: 30 |
0 commit comments