-
Notifications
You must be signed in to change notification settings - Fork 0
131 lines (121 loc) · 6.16 KB
/
Copy pathfte-report.yml
File metadata and controls
131 lines (121 loc) · 6.16 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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
name: FTE Capacity Report
# VEDA GitHub Actions test station — this workflow DOGFOODS the reusable action in `action.yml`
# (the same way another repo would import it), then publishes the result to a `fte-report/<pi>`
# branch + opens a living PR. The public Netlify dashboard reads `fte-report/all-pis` at runtime.
#
# Another repo would use just:
# - uses: NASA-IMPACT/veda-github-actions@v1
# with:
# project-url: https://github.com/orgs/THEIR-ORG/projects/5
# token: ${{ secrets.PROJECT_TOKEN_FOR_BOARD_READS }}
on:
workflow_dispatch:
inputs:
pi:
description: 'Program Increment to report on'
type: choice
required: true
default: 'All PIs'
options:
- 'All PIs'
- 'PI 26.4'
- 'PI 27.1'
- 'PI 27.2'
# Manual-only by design: this report is run on demand via the "Run workflow" button (with the
# PI dropdown above), not on a timer. The weekly schedule below is intentionally disabled so it
# doesn't push commits / refresh the living PR / trigger Netlify previews unattended — uncomment
# to restore the Monday auto-run.
# schedule:
# - cron: '0 13 * * 1' # Mondays 13:00 UTC
# Optional test hook: re-run when an Objective issue changes. Left OFF by default so a seed
# run doesn't trigger a run-storm; uncomment to exercise issue-driven runs.
# issues:
# types: [opened, edited, closed, reopened]
permissions:
contents: write # push the report to the per-PI branch
pull-requests: write # open/refresh the living PR to main
env:
# This station's own board. A consuming repo would point this at THEIR project instead.
BOARD_URL: "https://github.com/users/kyle-lesinger/projects/2"
DASHBOARD_URL: "https://veda-github-actions.netlify.app" # live FTE dashboard (Netlify, prod=main)
jobs:
fte-report:
name: Build FTE capacity report
runs-on: ubuntu-latest
steps:
- name: "1 · Checkout repository"
uses: actions/checkout@v4
with:
fetch-depth: 0 # full history so per-PI branches can be based/pushed
- name: "2 · Resolve PI filter + target branch"
id: cfg
run: |
PI_INPUT="${{ github.event.inputs.pi }}"
if [ "$PI_INPUT" = "All PIs" ]; then PI_INPUT=""; fi # dropdown default / other triggers
LABEL="${PI_INPUT:-all PIs}"
SLUG="$(echo "${PI_INPUT:-all-pis}" | tr ' ' '-' | tr -cd 'A-Za-z0-9._-')"
echo "pi=$PI_INPUT" >> "$GITHUB_OUTPUT"
echo "label=$LABEL" >> "$GITHUB_OUTPUT"
echo "slug=$SLUG" >> "$GITHUB_OUTPUT"
echo "branch=fte-report/$SLUG" >> "$GITHUB_OUTPUT"
echo "Event: $GITHUB_EVENT_NAME | PI: '$LABEL' | target branch: fte-report/$SLUG"
- name: "3 · Generate the report (reusable action — same import a consumer would use)"
uses: ./
with:
project-url: ${{ env.BOARD_URL }}
token: ${{ secrets.PROJECT_TOKEN_FOR_BOARD_READS }}
pi: ${{ steps.cfg.outputs.pi }}
out-dir: reports
- name: "4 · Publish report to the per-PI branch"
run: |
BR="${{ steps.cfg.outputs.branch }}"
mkdir -p "$RUNNER_TEMP/out" && cp -R reports/. "$RUNNER_TEMP/out/" # stash before switching branches
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Continue the per-PI branch if it exists (commits accumulate), else start it from main.
git fetch origin "$BR" || true
if git rev-parse --verify --quiet "origin/$BR"; then
git checkout -f -B "$BR" "origin/$BR"
else
git checkout -f -B "$BR"
fi
rm -rf reports && mkdir reports && cp -R "$RUNNER_TEMP/out/." reports/
git add -f reports
if git diff --cached --quiet; then
echo "No report changes for $BR."
else
git commit -m "FTE report — ${{ steps.cfg.outputs.label }} (run ${{ github.run_id }})"
git push origin "$BR"
echo "Report pushed to branch: $BR"
fi
- name: "5 · Upload report as build artifact"
uses: actions/upload-artifact@v4
with:
name: fte-report-${{ steps.cfg.outputs.slug }}
path: reports/
- name: "6 · Open/refresh the living PR to main"
env:
GH_TOKEN: ${{ github.token }} # default token has pull-requests: write (see permissions)
run: |
BR="${{ steps.cfg.outputs.branch }}"
git fetch origin main "$BR" --quiet || true
if [ "$(git rev-list --count "origin/main..origin/$BR" 2>/dev/null || echo 0)" = "0" ]; then
echo "$BR has no commits ahead of main — nothing to PR."
exit 0
fi
existing="$(gh pr list --head "$BR" --base main --state open --json number --jq '.[0].number // empty')"
if [ -n "$existing" ]; then
echo "PR #$existing already open for $BR — new commits refresh it automatically."
else
body="$(printf 'Automated LOE/FTE capacity report for **%s** (run %s).\n\n📊 **Dashboard:** %s — interactive view of the latest all-PIs report; it reads `fte-report/all-pis` live, so it always reflects the newest run.\n📋 **Project board:** %s\n\nReport files are in `reports/` on this branch. Merge to snapshot this report into `main`, or leave open as a living view.' "${{ steps.cfg.outputs.label }}" "${{ github.run_id }}" "$DASHBOARD_URL" "$BOARD_URL")"
gh pr create --head "$BR" --base main \
--title "FTE report — ${{ steps.cfg.outputs.label }}" \
--body "$body"
echo "Opened a PR from $BR to main."
fi
- name: "7 · Restore the default checkout"
# Step 4 switched the working tree to the fte-report/<pi> branch (which has no action.yml).
# The local `uses: ./` action runs a post-cleanup (setup-python) that re-resolves action.yml
# from the workspace, so put main's tree back before the job's post phase.
if: always()
run: git checkout -f "${{ github.sha }}" 2>/dev/null || git checkout -f main