|
7 | 7 | description: Exact candidate commit to verify from a trusted Pylon workflow |
8 | 8 | required: false |
9 | 9 | 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 |
10 | 15 | push: |
11 | 16 | branches: [pylon] |
12 | 17 | pull_request: |
|
26 | 31 | if: github.event_name != 'pull_request' || github.event.pull_request.draft == false |
27 | 32 | runs-on: ubuntu-latest |
28 | 33 | 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' }} |
30 | 35 | 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 | +
|
31 | 54 | - name: Recognize the internal upstream sync pull request |
32 | 55 | id: sync |
33 | 56 | if: github.event_name == 'pull_request' |
@@ -167,14 +190,16 @@ jobs: |
167 | 190 |
|
168 | 191 | build-check-test: |
169 | 192 | name: build-check-test |
170 | | - if: always() && needs.trust.outputs.allowed == 'true' |
| 193 | + if: always() && (needs.trust.outputs.allowed == 'true' || inputs.require_trusted) |
171 | 194 | needs: [trust, build-check, test] |
172 | 195 | runs-on: ubuntu-latest |
173 | 196 | steps: |
174 | 197 | - name: Verify CI results |
175 | 198 | env: |
| 199 | + TRUST_ALLOWED: ${{ needs.trust.outputs.allowed }} |
176 | 200 | BUILD_CHECK_RESULT: ${{ needs.build-check.result }} |
177 | 201 | TEST_RESULT: ${{ needs.test.result }} |
178 | 202 | run: | |
| 203 | + test "$TRUST_ALLOWED" = true |
179 | 204 | test "$BUILD_CHECK_RESULT" = success |
180 | 205 | test "$TEST_RESULT" = success |
0 commit comments