|
| 1 | +name: Theme Momentum Snapshot |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + inputs: |
| 6 | + as_of: |
| 7 | + description: "Optional YYYY-MM-DD cutoff. Empty uses latest available/downloaded price date." |
| 8 | + required: false |
| 9 | + type: string |
| 10 | + prices_path: |
| 11 | + description: "Optional local price CSV path. Empty downloads Yahoo chart data as a temporary fallback." |
| 12 | + required: false |
| 13 | + default: "" |
| 14 | + type: string |
| 15 | + strict_downloads: |
| 16 | + description: "Fail if any downloaded symbol is unavailable." |
| 17 | + required: false |
| 18 | + default: "false" |
| 19 | + type: choice |
| 20 | + options: |
| 21 | + - "false" |
| 22 | + - "true" |
| 23 | + commit_outputs: |
| 24 | + description: "Commit generated theme_momentum_snapshot.json back to data/output." |
| 25 | + required: false |
| 26 | + default: "false" |
| 27 | + type: choice |
| 28 | + options: |
| 29 | + - "false" |
| 30 | + - "true" |
| 31 | + schedule: |
| 32 | + # Refresh before the advisory publication workflow. The script records data |
| 33 | + # source and hash metadata; downstream use remains research-only. |
| 34 | + - cron: "45 11 * * 6" |
| 35 | + |
| 36 | +permissions: |
| 37 | + contents: write |
| 38 | + |
| 39 | +jobs: |
| 40 | + build-theme-momentum: |
| 41 | + runs-on: ubuntu-latest |
| 42 | + steps: |
| 43 | + - uses: actions/checkout@v6 |
| 44 | + - uses: actions/setup-python@v6 |
| 45 | + with: |
| 46 | + python-version: "3.11" |
| 47 | + - name: Install package |
| 48 | + run: python -m pip install -e . |
| 49 | + - name: Build theme momentum snapshot |
| 50 | + env: |
| 51 | + INPUT_AS_OF: ${{ github.event.inputs.as_of || '' }} |
| 52 | + PRICES_PATH: ${{ github.event.inputs.prices_path || '' }} |
| 53 | + STRICT_DOWNLOADS: ${{ github.event.inputs.strict_downloads || 'false' }} |
| 54 | + run: | |
| 55 | + set -euo pipefail |
| 56 | + mkdir -p data/output |
| 57 | + ARGS=(--output data/output/theme_momentum_snapshot.json) |
| 58 | + if [ -n "${INPUT_AS_OF}" ]; then |
| 59 | + ARGS+=(--as-of "${INPUT_AS_OF}") |
| 60 | + fi |
| 61 | + if [ -n "${PRICES_PATH}" ]; then |
| 62 | + ARGS+=(--prices "${PRICES_PATH}") |
| 63 | + fi |
| 64 | + if [ "${STRICT_DOWNLOADS}" = "true" ]; then |
| 65 | + ARGS+=(--strict-downloads) |
| 66 | + fi |
| 67 | + python scripts/build_theme_momentum_snapshot.py "${ARGS[@]}" | tee /tmp/theme_momentum_summary.json |
| 68 | + { |
| 69 | + echo "## Theme momentum snapshot" |
| 70 | + echo "" |
| 71 | + echo '```json' |
| 72 | + cat /tmp/theme_momentum_summary.json |
| 73 | + echo '```' |
| 74 | + } >> "$GITHUB_STEP_SUMMARY" |
| 75 | + - name: Commit snapshot |
| 76 | + env: |
| 77 | + COMMIT_OUTPUTS: ${{ github.event_name == 'schedule' && 'true' || github.event.inputs.commit_outputs || 'false' }} |
| 78 | + run: | |
| 79 | + set -euo pipefail |
| 80 | + if [ "${COMMIT_OUTPUTS}" != "true" ]; then |
| 81 | + echo "Snapshot commit disabled." |
| 82 | + exit 0 |
| 83 | + fi |
| 84 | + git config user.name "github-actions[bot]" |
| 85 | + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" |
| 86 | + git add data/output/theme_momentum_snapshot.json |
| 87 | + if git diff --cached --quiet; then |
| 88 | + echo "No theme momentum changes to commit." |
| 89 | + else |
| 90 | + git commit -m "Update theme momentum snapshot [skip ci]" |
| 91 | + git push |
| 92 | + fi |
| 93 | + - name: Upload theme momentum artifact |
| 94 | + uses: actions/upload-artifact@v7 |
| 95 | + with: |
| 96 | + name: theme-momentum-snapshot |
| 97 | + path: data/output/theme_momentum_snapshot.json |
| 98 | + if-no-files-found: error |
0 commit comments