سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 18:15 UTC
ci: add exact-SHA Quality Security DB promotion gate
davoodmehraban89 committed
Oct 1, 2026 at 23:59 UTC
671a40684027e82b19fce9bdd3c92d031763c6f9
1 file changed
+76
.github/workflows/release-gate.yml
new
+76
@@ -0,0 +1,76 @@
1
+name: Release gate
2
+
3
+on:
4
+ workflow_run:
5
+ workflows: ["Quality checks", "Security checks"]
6
+ types: [completed]
7
+
8
+permissions:
9
+ actions: read
10
+ contents: read
11
+
12
+concurrency:
13
+ group: release-gate-${{ github.event.workflow_run.head_sha }}
14
+ cancel-in-progress: true
15
+
16
+jobs:
17
+ exact-sha-gate:
18
+ name: Exact SHA promotion gate
19
+ if: github.event.workflow_run.head_branch == 'main'
20
+ runs-on: ubuntu-latest
21
+ timeout-minutes: 25
22
+ steps:
23
+ - name: Wait for required exact-SHA workflows
24
+ env:
25
+ GH_TOKEN: ${{ github.token }}
26
+ REPO: ${{ github.repository }}
27
+ HEAD_SHA: ${{ github.event.workflow_run.head_sha }}
28
+ run: |
29
+ set -euo pipefail
30
+ get_success_run() {
31
+ local workflow="$1"
32
+ gh api -H 'Accept: application/vnd.github+json' \
33
+ "repos/$REPO/actions/workflows/$workflow/runs?head_sha=$HEAD_SHA&per_page=20" \
34
+ --jq '[.workflow_runs[] | select(.head_sha == env.HEAD_SHA and .status == "completed" and .conclusion == "success")] | sort_by(.run_number) | last | .id // empty'
35
+ }
36
+
37
+ quality_id=''
38
+ security_id=''
39
+ for attempt in $(seq 1 40); do
40
+ quality_id="$(get_success_run quality.yml)"
41
+ security_id="$(get_success_run security.yml)"
42
+ if [ -n "$quality_id" ] && [ -n "$security_id" ]; then break; fi
43
+ echo "Waiting for exact-SHA Quality/Security success ($attempt/40)..."
44
+ sleep 30
45
+ done
46
+
47
+ test -n "$quality_id" || { echo '::error::No successful Quality run for exact SHA'; exit 1; }
48
+ test -n "$security_id" || { echo '::error::No successful Security run for exact SHA'; exit 1; }
49
+
50
+ gh api "repos/$REPO/actions/runs/$quality_id/jobs?per_page=100" > quality-jobs.json
51
+ for required in static-quality c8-policy-database d1-request-database; do
52
+ conclusion="$(jq -r --arg n "$required" '[.jobs[] | select(.name == $n)] | last | .conclusion // empty' quality-jobs.json)"
53
+ test "$conclusion" = success || { echo "::error::Required DB/quality job $required is not successful for $HEAD_SHA"; exit 1; }
54
+ done
55
+
56
+ printf 'HEAD_SHA=%s\nQUALITY_RUN_ID=%s\nSECURITY_RUN_ID=%s\n' "$HEAD_SHA" "$quality_id" "$security_id" > release-gate.env
57
+ {
58
+ echo '## Exact-SHA release gate'
59
+ echo "- SHA: \`$HEAD_SHA\`"
60
+ echo "- Quality run: \`$quality_id\`"
61
+ echo "- Security run: \`$security_id\`"
62
+ echo '- Required Quality/DB jobs: static-quality, c8-policy-database, d1-request-database = SUCCESS'
63
+ echo '- Result: PROMOTION GATE PASSED'
64
+ echo '- Note: repository branch protection / Pages source must independently enforce this gate before deployment.'
65
+ } | tee release-gate.md >> "$GITHUB_STEP_SUMMARY"
66
+
67
+ - name: Upload bounded release-gate evidence
68
+ uses: actions/upload-artifact@v4
69
+ with:
70
+ name: release-gate-${{ github.event.workflow_run.head_sha }}
71
+ retention-days: 14
72
+ path: |
73
+ release-gate.env
74
+ release-gate.md
75
+ quality-jobs.json
76
+ if-no-files-found: error