@plainconceptsplatform/workflows 0.4.11 → 0.4.12
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.
|
@@ -11,7 +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="*/
|
|
14
|
+
readonly RECONCILE_BOT_PR_RUNS_CRON="*/15 * * * *"
|
|
15
15
|
readonly STALE_RECOVERY_CRON="0 */2 * * *"
|
|
16
16
|
# Daily, but it proposes far less often than daily: the worker holds one open
|
|
17
17
|
# proposal at a time and skips while that slot is filled. The cron is a heartbeat,
|
|
@@ -78,7 +78,17 @@ classify_route() {
|
|
|
78
78
|
;;
|
|
79
79
|
|
|
80
80
|
pull_request_target)
|
|
81
|
-
|
|
81
|
+
if [ "${ACTION:-}" = "labeled" ] && [ "${LABEL:-}" = "merge-gate" ]; then
|
|
82
|
+
# Human adds merge-gate label to bot PR → triggers merge-gate with human actor
|
|
83
|
+
# This bypasses gh-aw's bot membership check since the actor is human
|
|
84
|
+
route="merge-gate"
|
|
85
|
+
pr_number="${EVENT_PR_NUMBER:-}"
|
|
86
|
+
# CI status will be fetched by the merge-gate workflow
|
|
87
|
+
ci_conclusion=""
|
|
88
|
+
ci_run_id=""
|
|
89
|
+
else
|
|
90
|
+
route="bot-approve"
|
|
91
|
+
fi
|
|
82
92
|
;;
|
|
83
93
|
|
|
84
94
|
workflow_run)
|
|
@@ -9,8 +9,9 @@ inputs:
|
|
|
9
9
|
description: Pull request number to gate.
|
|
10
10
|
required: true
|
|
11
11
|
ci-conclusion:
|
|
12
|
-
description: Conclusion reported by the CI run that triggered this gate.
|
|
13
|
-
required:
|
|
12
|
+
description: Conclusion reported by the CI run that triggered this gate. If empty, fetches from the PR's latest CI run.
|
|
13
|
+
required: false
|
|
14
|
+
default: ''
|
|
14
15
|
linked-issue:
|
|
15
16
|
description: Issue the pull request closes, when the router already resolved it.
|
|
16
17
|
required: false
|
|
@@ -30,8 +31,11 @@ outputs:
|
|
|
30
31
|
description: Issue number the pull request closes.
|
|
31
32
|
value: ${{ steps.identify.outputs.issue }}
|
|
32
33
|
conclusion:
|
|
33
|
-
description: CI conclusion, passed through unchanged.
|
|
34
|
+
description: CI conclusion, passed through unchanged or fetched from latest CI run.
|
|
34
35
|
value: ${{ steps.identify.outputs.conclusion }}
|
|
36
|
+
run-id:
|
|
37
|
+
description: CI run ID when fetched.
|
|
38
|
+
value: ${{ steps.identify.outputs.run-id }}
|
|
35
39
|
runs:
|
|
36
40
|
using: composite
|
|
37
41
|
steps:
|
|
@@ -87,11 +91,30 @@ runs:
|
|
|
87
91
|
fi
|
|
88
92
|
fi
|
|
89
93
|
|
|
94
|
+
# Fetch CI conclusion if not provided (label-triggered runs)
|
|
95
|
+
ci_conclusion="$CONCLUSION"
|
|
96
|
+
ci_run_id=""
|
|
97
|
+
if [ -z "$ci_conclusion" ]; then
|
|
98
|
+
head_sha="$(gh pr view "$PR_NUMBER" --repo "$REPO" --json headRefOid --jq '.headRefOid')"
|
|
99
|
+
ci_run="$(gh api "repos/$REPO/actions/runs?head_sha=$head_sha&per_page=100" \
|
|
100
|
+
--jq '[.workflow_runs[] | select(.name == "App: CI" or .name == "CI")] | sort_by(.created_at) | last')"
|
|
101
|
+
|
|
102
|
+
if [ -n "$ci_run" ] && [ "$ci_run" != "null" ]; then
|
|
103
|
+
ci_conclusion="$(jq -r '.conclusion // "pending"' <<<"$ci_run")"
|
|
104
|
+
ci_run_id="$(jq -r '.id' <<<"$ci_run")"
|
|
105
|
+
echo "::notice::Fetched CI status: $ci_conclusion (run $ci_run_id)"
|
|
106
|
+
else
|
|
107
|
+
ci_conclusion="unknown"
|
|
108
|
+
echo "::warning::No CI run found for PR #$PR_NUMBER"
|
|
109
|
+
fi
|
|
110
|
+
fi
|
|
111
|
+
|
|
90
112
|
{
|
|
91
113
|
echo "found=true"
|
|
92
114
|
echo "pr=$PR_NUMBER"
|
|
93
115
|
echo "issue=$issue"
|
|
94
|
-
echo "conclusion=$
|
|
116
|
+
echo "conclusion=$ci_conclusion"
|
|
117
|
+
echo "run-id=$ci_run_id"
|
|
95
118
|
} >> "$GITHUB_OUTPUT"
|
|
96
119
|
|
|
97
|
-
echo "PR #$PR_NUMBER closes #$issue; CI concluded $
|
|
120
|
+
echo "PR #$PR_NUMBER closes #$issue; CI concluded $ci_conclusion"
|
|
@@ -37,7 +37,7 @@ on:
|
|
|
37
37
|
types: [submitted]
|
|
38
38
|
|
|
39
39
|
pull_request_target:
|
|
40
|
-
types: [opened, synchronize, reopened]
|
|
40
|
+
types: [opened, synchronize, reopened, labeled]
|
|
41
41
|
workflow_run:
|
|
42
42
|
workflows: ["App: CI", "CI"]
|
|
43
43
|
types: [completed]
|
|
@@ -54,7 +54,7 @@ on:
|
|
|
54
54
|
- cron: "17 1 * * 1"
|
|
55
55
|
- cron: "43 3 * * *"
|
|
56
56
|
- cron: "0 6 * * *"
|
|
57
|
-
- cron: "*/
|
|
57
|
+
- cron: "*/15 * * * *"
|
|
58
58
|
- cron: "0 */2 * * *"
|
|
59
59
|
- cron: "29 7 * * *"
|
|
60
60
|
|
|
@@ -356,19 +356,25 @@ jobs:
|
|
|
356
356
|
runs-on: ubuntu-latest
|
|
357
357
|
timeout-minutes: 5
|
|
358
358
|
permissions:
|
|
359
|
+
contents: read
|
|
359
360
|
actions: write
|
|
360
361
|
pull-requests: read
|
|
362
|
+
env:
|
|
363
|
+
BOT_APP_ID: ${{ secrets.BOT_APP_ID }}
|
|
364
|
+
BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }}
|
|
361
365
|
steps:
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
366
|
+
- name: Checkout for App token action
|
|
367
|
+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
368
|
+
with:
|
|
369
|
+
persist-credentials: false
|
|
370
|
+
- name: Generate App token
|
|
365
371
|
id: app-token
|
|
366
|
-
uses: actions/create-github-app-token@
|
|
372
|
+
uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6
|
|
367
373
|
with:
|
|
368
|
-
|
|
374
|
+
app-id: ${{ secrets.BOT_APP_ID }}
|
|
369
375
|
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
|
|
370
|
-
|
|
371
|
-
|
|
376
|
+
# Runs only the default-branch workflow and never checks out pull-request code.
|
|
377
|
+
# External users cannot impersonate github-actions[bot].
|
|
372
378
|
- name: Approve checks and dispatch Merge Gate for trusted bot pull requests
|
|
373
379
|
env:
|
|
374
380
|
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
@@ -383,6 +389,7 @@ jobs:
|
|
|
383
389
|
| select(
|
|
384
390
|
.user.login == "github-actions[bot]"
|
|
385
391
|
and .head.repo.full_name == $repo
|
|
392
|
+
and .mergeable_state != "dirty"
|
|
386
393
|
)
|
|
387
394
|
| [.number, .head.ref] | @tsv
|
|
388
395
|
' |
|
|
@@ -427,6 +434,7 @@ jobs:
|
|
|
427
434
|
-f "inputs[pr-number]=$pr_number" \
|
|
428
435
|
-f "inputs[ci-conclusion]=$ci_conclusion" \
|
|
429
436
|
-f "inputs[ci-run-id]=$ci_run_id"
|
|
437
|
+
done
|
|
430
438
|
|
|
431
439
|
audit-close:
|
|
432
440
|
needs: classify
|