-
Notifications
You must be signed in to change notification settings - Fork 0
71 lines (64 loc) · 2.39 KB
/
Copy pathpr-guard.yml
File metadata and controls
71 lines (64 loc) · 2.39 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
name: PR Guard
on:
pull_request:
workflow_dispatch:
inputs:
base_ref:
description: Base git ref
required: false
head_ref:
description: Head git ref
required: false
permissions:
contents: read
jobs:
guard:
name: guard
runs-on: ubuntu-latest
steps:
- name: Checkout PR content
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha || github.sha }}
- name: Checkout trusted gate scripts
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
ref: ${{ github.event.repository.default_branch }}
path: .gate-trusted
fetch-depth: 1
- name: Resolve diff refs
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
INPUT_BASE_REF: ${{ inputs.base_ref }}
INPUT_HEAD_REF: ${{ inputs.head_ref }}
run: |
set -euo pipefail
if [ "${EVENT_NAME}" = "pull_request" ]; then
base_ref="${PR_BASE_SHA}"
head_ref="${PR_HEAD_SHA}"
else
base_ref="${INPUT_BASE_REF:-HEAD~1}"
head_ref="${INPUT_HEAD_REF:-HEAD}"
fi
echo "BASE_REF=$base_ref" >> "$GITHUB_ENV"
echo "HEAD_REF=$head_ref" >> "$GITHUB_ENV"
- name: Require complete feature memory
run: |
if [ -f .gate-trusted/scripts/check-feature-memory.mjs ]; then
node .gate-trusted/scripts/check-feature-memory.mjs "$BASE_REF" "$HEAD_REF"
else
echo "::warning::Trusted gate script missing on default branch; using PR script for first-install bootstrap only."
node scripts/check-feature-memory.mjs "$BASE_REF" "$HEAD_REF"
fi
- name: Validate baseline files
run: |
if [ -f .gate-trusted/scripts/check-repo-baseline.mjs ]; then
node .gate-trusted/scripts/check-repo-baseline.mjs --target "$GITHUB_WORKSPACE"
else
echo "::warning::Trusted baseline script missing on default branch; using PR script for first-install bootstrap only."
node scripts/check-repo-baseline.mjs --target "$GITHUB_WORKSPACE"
fi