@plainconceptsplatform/workflows 0.4.9 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -9,6 +9,7 @@ on:
|
|
|
9
9
|
- cron: "17 1 * * 1"
|
|
10
10
|
- cron: "43 3 * * *"
|
|
11
11
|
- cron: "0 6 * * *"
|
|
12
|
+
- cron: "*/5 * * * *"
|
|
12
13
|
- cron: "0 */2 * * *"
|
|
13
14
|
- cron: "29 7 * * *"
|
|
14
15
|
|
|
@@ -28,6 +29,7 @@ on:
|
|
|
28
29
|
- propose
|
|
29
30
|
- audit-close
|
|
30
31
|
- cleanup-artifacts
|
|
32
|
+
- reconcile-bot-pr-runs
|
|
31
33
|
- stale-recovery
|
|
32
34
|
- validate
|
|
33
35
|
|
|
@@ -71,6 +73,7 @@ set -euo pipefail
|
|
|
71
73
|
readonly AUDIT_CRON="17 1 * * 1"
|
|
72
74
|
readonly AUDIT_CLOSE_CRON="43 3 * * *"
|
|
73
75
|
readonly CLEANUP_ARTIFACTS_CRON="0 6 * * *"
|
|
76
|
+
readonly RECONCILE_BOT_PR_RUNS_CRON="*/5 * * * *"
|
|
74
77
|
readonly STALE_RECOVERY_CRON="0 */2 * * *"
|
|
75
78
|
readonly PROPOSE_CRON="29 7 * * *"
|
|
76
79
|
|
|
@@ -84,6 +87,7 @@ classify_route() {
|
|
|
84
87
|
"\$AUDIT_CRON") route="audit" ;;
|
|
85
88
|
"\$AUDIT_CLOSE_CRON") route="audit-close" ;;
|
|
86
89
|
"\$CLEANUP_ARTIFACTS_CRON") route="cleanup-artifacts" ;;
|
|
90
|
+
"\$RECONCILE_BOT_PR_RUNS_CRON") route="reconcile-bot-pr-runs" ;;
|
|
87
91
|
"\$STALE_RECOVERY_CRON") route="stale-recovery" ;;
|
|
88
92
|
"\$PROPOSE_CRON") route="propose" ;;
|
|
89
93
|
*) error="no route for cron '\${SCHEDULE:-}'" ;;
|
|
@@ -106,7 +110,7 @@ classify_route() {
|
|
|
106
110
|
route="\${OPERATION}"
|
|
107
111
|
trigger_kind="\${INPUT_TRIGGER_KIND:-manual}"
|
|
108
112
|
;;
|
|
109
|
-
audit-close | cleanup-artifacts | stale-recovery | validate)
|
|
113
|
+
audit-close | cleanup-artifacts | reconcile-bot-pr-runs | stale-recovery | validate)
|
|
110
114
|
route="\${OPERATION}"
|
|
111
115
|
;;
|
|
112
116
|
*)
|
|
@@ -131,7 +135,7 @@ set -euo pipefail
|
|
|
131
135
|
|
|
132
136
|
echo "── Router wiring ─────────────────────────────────────────────────────────"
|
|
133
137
|
for route in refine implement direct apply-review merge-gate audit propose bot-approve \\
|
|
134
|
-
audit-close cleanup-artifacts stale-recovery validate; do
|
|
138
|
+
audit-close cleanup-artifacts reconcile-bot-pr-runs stale-recovery validate; do
|
|
135
139
|
if grep -q "route == '\${route}'" "\$ROUTER_YML"; then
|
|
136
140
|
PASS=\$((PASS + 1))
|
|
137
141
|
else
|
|
@@ -11,6 +11,7 @@ set -euo pipefail
|
|
|
11
11
|
readonly AUDIT_CRON="17 1 * * 1"
|
|
12
12
|
readonly AUDIT_CLOSE_CRON="43 3 * * *"
|
|
13
13
|
readonly CLEANUP_ARTIFACTS_CRON="0 6 * * *"
|
|
14
|
+
readonly RECONCILE_BOT_PR_RUNS_CRON="*/5 * * * *"
|
|
14
15
|
readonly STALE_RECOVERY_CRON="0 */2 * * *"
|
|
15
16
|
# Daily, but it proposes far less often than daily: the worker holds one open
|
|
16
17
|
# proposal at a time and skips while that slot is filled. The cron is a heartbeat,
|
|
@@ -97,6 +98,7 @@ classify_route() {
|
|
|
97
98
|
"$AUDIT_CRON") route="audit" ;;
|
|
98
99
|
"$AUDIT_CLOSE_CRON") route="audit-close" ;;
|
|
99
100
|
"$CLEANUP_ARTIFACTS_CRON") route="cleanup-artifacts" ;;
|
|
101
|
+
"$RECONCILE_BOT_PR_RUNS_CRON") route="reconcile-bot-pr-runs" ;;
|
|
100
102
|
"$STALE_RECOVERY_CRON") route="stale-recovery" ;;
|
|
101
103
|
"$PROPOSE_CRON") route="propose" ;;
|
|
102
104
|
*) error="no route for cron '${SCHEDULE:-}'" ;;
|
|
@@ -141,7 +143,7 @@ classify_route() {
|
|
|
141
143
|
route="${OPERATION}"
|
|
142
144
|
trigger_kind="${INPUT_TRIGGER_KIND:-manual}"
|
|
143
145
|
;;
|
|
144
|
-
audit-close | cleanup-artifacts | stale-recovery | validate)
|
|
146
|
+
audit-close | cleanup-artifacts | reconcile-bot-pr-runs | stale-recovery | validate)
|
|
145
147
|
route="${OPERATION}"
|
|
146
148
|
;;
|
|
147
149
|
*)
|
|
@@ -148,6 +148,8 @@ assert_route "merge-gate dispatch accepts a positive pull request" merge-gate \
|
|
|
148
148
|
EVENT=workflow_dispatch OPERATION=merge-gate INPUT_PR_NUMBER=7
|
|
149
149
|
assert_route "stale-recovery dispatch needs no numbers" stale-recovery \
|
|
150
150
|
EVENT=workflow_dispatch OPERATION=stale-recovery
|
|
151
|
+
assert_route "reconcile-bot-pr-runs dispatch needs no numbers" reconcile-bot-pr-runs \
|
|
152
|
+
EVENT=workflow_dispatch OPERATION=reconcile-bot-pr-runs
|
|
151
153
|
assert_route "an unknown operation routes nowhere" none \
|
|
152
154
|
EVENT=workflow_dispatch OPERATION=deploy-everything
|
|
153
155
|
assert "a scheduled audit reports its trigger kind" scheduled \
|
|
@@ -184,7 +186,7 @@ for route in refine implement direct apply-review; do
|
|
|
184
186
|
done
|
|
185
187
|
|
|
186
188
|
for route in refine implement direct apply-review merge-gate audit propose bot-approve \
|
|
187
|
-
audit-close cleanup-artifacts stale-recovery validate; do
|
|
189
|
+
audit-close cleanup-artifacts reconcile-bot-pr-runs stale-recovery validate; do
|
|
188
190
|
if grep -q "route == '${route}'" "$ROUTER_YML"; then
|
|
189
191
|
PASS=$((PASS + 1))
|
|
190
192
|
else
|
|
@@ -54,6 +54,7 @@ on:
|
|
|
54
54
|
- cron: "17 1 * * 1"
|
|
55
55
|
- cron: "43 3 * * *"
|
|
56
56
|
- cron: "0 6 * * *"
|
|
57
|
+
- cron: "*/5 * * * *"
|
|
57
58
|
- cron: "0 */2 * * *"
|
|
58
59
|
- cron: "29 7 * * *"
|
|
59
60
|
|
|
@@ -73,6 +74,7 @@ on:
|
|
|
73
74
|
- propose
|
|
74
75
|
- audit-close
|
|
75
76
|
- cleanup-artifacts
|
|
77
|
+
- reconcile-bot-pr-runs
|
|
76
78
|
- stale-recovery
|
|
77
79
|
- validate
|
|
78
80
|
issue-number:
|
|
@@ -348,6 +350,84 @@ jobs:
|
|
|
348
350
|
gh api "repos/$REPO/actions/runs/$run_id/approve" --method POST
|
|
349
351
|
done
|
|
350
352
|
|
|
353
|
+
reconcile-bot-pr-runs:
|
|
354
|
+
needs: classify
|
|
355
|
+
if: needs.classify.outputs.route == 'reconcile-bot-pr-runs'
|
|
356
|
+
runs-on: ubuntu-latest
|
|
357
|
+
timeout-minutes: 5
|
|
358
|
+
permissions:
|
|
359
|
+
actions: write
|
|
360
|
+
pull-requests: read
|
|
361
|
+
steps:
|
|
362
|
+
# Runs only the default-branch workflow and never checks out pull-request code.
|
|
363
|
+
# External users cannot impersonate github-actions[bot].
|
|
364
|
+
- name: Create Platform bot token
|
|
365
|
+
id: app-token
|
|
366
|
+
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
|
367
|
+
with:
|
|
368
|
+
client-id: ${{ secrets.BOT_APP_ID }}
|
|
369
|
+
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
|
|
370
|
+
permission-actions: write
|
|
371
|
+
permission-pull-requests: read
|
|
372
|
+
- name: Approve checks and dispatch Merge Gate for trusted bot pull requests
|
|
373
|
+
env:
|
|
374
|
+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
375
|
+
REPO: ${{ github.repository }}
|
|
376
|
+
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
|
377
|
+
run: |
|
|
378
|
+
set -euo pipefail
|
|
379
|
+
|
|
380
|
+
gh api "repos/$REPO/pulls?state=open&per_page=100" |
|
|
381
|
+
jq -r --arg repo "$REPO" '
|
|
382
|
+
.[]
|
|
383
|
+
| select(
|
|
384
|
+
.user.login == "github-actions[bot]"
|
|
385
|
+
and .head.repo.full_name == $repo
|
|
386
|
+
)
|
|
387
|
+
| [.number, .head.ref] | @tsv
|
|
388
|
+
' |
|
|
389
|
+
while IFS=$'\t' read -r pr_number branch; do
|
|
390
|
+
gh api "repos/$REPO/actions/runs?status=action_required&branch=$branch" \
|
|
391
|
+
--jq '.workflow_runs[]
|
|
392
|
+
| select(
|
|
393
|
+
.event == "pull_request"
|
|
394
|
+
and (.name == "App: CI" or .name == "Visual evidence")
|
|
395
|
+
)
|
|
396
|
+
| .id' |
|
|
397
|
+
while IFS= read -r run_id; do
|
|
398
|
+
echo "Approving trusted bot run $run_id"
|
|
399
|
+
gh api "repos/$REPO/actions/runs/$run_id/approve" --method POST
|
|
400
|
+
done
|
|
401
|
+
|
|
402
|
+
gate_recorded=$(gh api "repos/$REPO/issues/$pr_number/comments?per_page=100" \
|
|
403
|
+
--jq 'any(.[]; .body | contains("<!-- agent-merge-gate -->"))')
|
|
404
|
+
if [ "$gate_recorded" = "true" ]; then
|
|
405
|
+
continue
|
|
406
|
+
fi
|
|
407
|
+
|
|
408
|
+
ci=$(gh api "repos/$REPO/actions/runs?branch=$branch&per_page=100" \
|
|
409
|
+
--jq '[.workflow_runs[]
|
|
410
|
+
| select(
|
|
411
|
+
.name == "App: CI"
|
|
412
|
+
and .event == "pull_request"
|
|
413
|
+
and .status == "completed"
|
|
414
|
+
and (.conclusion == "success" or .conclusion == "failure")
|
|
415
|
+
)
|
|
416
|
+
] | sort_by(.created_at) | last // empty | [.id, .conclusion] | @tsv')
|
|
417
|
+
if [ -z "$ci" ]; then
|
|
418
|
+
continue
|
|
419
|
+
fi
|
|
420
|
+
|
|
421
|
+
IFS=$'\t' read -r ci_run_id ci_conclusion <<<"$ci"
|
|
422
|
+
echo "Dispatching Merge Gate for PR #$pr_number ($ci_conclusion, run $ci_run_id)"
|
|
423
|
+
gh api "repos/$REPO/actions/workflows/work-router.yml/dispatches" \
|
|
424
|
+
--method POST \
|
|
425
|
+
-f ref="$DEFAULT_BRANCH" \
|
|
426
|
+
-f "inputs[operation]=merge-gate" \
|
|
427
|
+
-f "inputs[pr-number]=$pr_number" \
|
|
428
|
+
-f "inputs[ci-conclusion]=$ci_conclusion" \
|
|
429
|
+
-f "inputs[ci-run-id]=$ci_run_id"
|
|
430
|
+
|
|
351
431
|
audit-close:
|
|
352
432
|
needs: classify
|
|
353
433
|
if: needs.classify.outputs.route == 'audit-close'
|