Skip to content

Commit 8551520

Browse files
authored
Merge pull request #10 from pylon-code/fix/pylon-sync-candidate-ci
fix(ci): verify upstream sync candidates
2 parents 02a53dd + 5f8ff4e commit 8551520

2 files changed

Lines changed: 28 additions & 2 deletions

File tree

.github/workflows/ci.yml

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ on:
77
description: Exact candidate commit to verify from a trusted Pylon workflow
88
required: false
99
type: string
10+
require_trusted:
11+
description: Fail the aggregate when a trusted caller is not recognized
12+
required: false
13+
default: false
14+
type: boolean
1015
push:
1116
branches: [pylon]
1217
pull_request:
@@ -26,8 +31,26 @@ jobs:
2631
if: github.event_name != 'pull_request' || github.event.pull_request.draft == false
2732
runs-on: ubuntu-latest
2833
outputs:
29-
allowed: ${{ github.event_name == 'workflow_call' || github.event_name == 'push' || steps.sync.outputs.allowed == 'true' || steps.vouch.outputs.vouched == 'true' }}
34+
allowed: ${{ steps.internal.outputs.allowed == 'true' || steps.sync.outputs.allowed == 'true' || steps.vouch.outputs.vouched == 'true' }}
3035
steps:
36+
- name: Recognize a trusted Pylon execution
37+
id: internal
38+
if: github.event_name == 'push' || inputs.checkout_ref != ''
39+
env:
40+
CHECKOUT_REF: ${{ inputs.checkout_ref }}
41+
CALLER_EVENT: ${{ github.event_name }}
42+
CALLER_REF: ${{ github.ref }}
43+
CALLER_REPOSITORY: ${{ github.repository }}
44+
run: |
45+
if [[ "$CALLER_REPOSITORY" != "pylon-code/prime-agent" || "$CALLER_REF" != "refs/heads/pylon" ]]; then
46+
exit 0
47+
fi
48+
if [[ "$CALLER_EVENT" == "push" && -z "$CHECKOUT_REF" ]]; then
49+
echo "allowed=true" >> "$GITHUB_OUTPUT"
50+
elif [[ ("$CALLER_EVENT" == "workflow_dispatch" || "$CALLER_EVENT" == "schedule") && "$CHECKOUT_REF" =~ ^[0-9a-f]{40}$ ]]; then
51+
echo "allowed=true" >> "$GITHUB_OUTPUT"
52+
fi
53+
3154
- name: Recognize the internal upstream sync pull request
3255
id: sync
3356
if: github.event_name == 'pull_request'
@@ -167,14 +190,16 @@ jobs:
167190

168191
build-check-test:
169192
name: build-check-test
170-
if: always() && needs.trust.outputs.allowed == 'true'
193+
if: always() && (needs.trust.outputs.allowed == 'true' || inputs.require_trusted)
171194
needs: [trust, build-check, test]
172195
runs-on: ubuntu-latest
173196
steps:
174197
- name: Verify CI results
175198
env:
199+
TRUST_ALLOWED: ${{ needs.trust.outputs.allowed }}
176200
BUILD_CHECK_RESULT: ${{ needs.build-check.result }}
177201
TEST_RESULT: ${{ needs.test.result }}
178202
run: |
203+
test "$TRUST_ALLOWED" = true
179204
test "$BUILD_CHECK_RESULT" = success
180205
test "$TEST_RESULT" = success

.github/workflows/pylon-upstream-sync.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,4 @@ jobs:
4646
uses: ./.github/workflows/ci.yml
4747
with:
4848
checkout_ref: ${{ needs.sync.outputs.candidate_sha }}
49+
require_trusted: true

0 commit comments

Comments
 (0)