|
25 | 25 | if: github.repository_owner == 'NVIDIA-NeMo' |
26 | 26 | runs-on: ubuntu-latest |
27 | 27 | steps: |
| 28 | + - name: Check trusted Agentic CI PR |
| 29 | + id: trusted-agentic-ci |
| 30 | + env: |
| 31 | + GH_TOKEN: ${{ github.token }} |
| 32 | + EVENT_NAME: ${{ github.event_name }} |
| 33 | + PR_AUTHOR: ${{ github.event.pull_request.user.login }} |
| 34 | + HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }} |
| 35 | + HEAD_REF: ${{ github.event.pull_request.head.ref }} |
| 36 | + PR_BODY: ${{ github.event.pull_request.body }} |
| 37 | + ISSUE_NUMBER: ${{ github.event.issue.number }} |
| 38 | + REPO: ${{ github.repository }} |
| 39 | + run: | |
| 40 | + TRUSTED=false |
| 41 | +
|
| 42 | + if [ "$EVENT_NAME" = "issue_comment" ] && [ -n "$ISSUE_NUMBER" ]; then |
| 43 | + PR_JSON=$(gh api "repos/${REPO}/pulls/${ISSUE_NUMBER}" 2>/dev/null || true) |
| 44 | + if [ -n "$PR_JSON" ]; then |
| 45 | + PR_AUTHOR=$(printf '%s' "$PR_JSON" | jq -r '.user.login') |
| 46 | + HEAD_REPO=$(printf '%s' "$PR_JSON" | jq -r '.head.repo.full_name') |
| 47 | + HEAD_REF=$(printf '%s' "$PR_JSON" | jq -r '.head.ref') |
| 48 | + PR_BODY=$(printf '%s' "$PR_JSON" | jq -r '.body // ""') |
| 49 | + fi |
| 50 | + fi |
| 51 | +
|
| 52 | + printf '%s' "$PR_BODY" > /tmp/pr-body-raw.txt |
| 53 | + # Commit authors can be spoofed; trust only PR metadata GitHub controls. |
| 54 | + if { [ "$PR_AUTHOR" = "github-actions[bot]" ] || [ "$PR_AUTHOR" = "agentic-ci" ]; } && \ |
| 55 | + [ "$HEAD_REPO" = "$REPO" ] && \ |
| 56 | + [[ "$HEAD_REF" == agentic-ci/* ]] && \ |
| 57 | + grep -q '<!-- agentic-ci ' /tmp/pr-body-raw.txt; then |
| 58 | + TRUSTED=true |
| 59 | + fi |
| 60 | +
|
| 61 | + echo "trusted=${TRUSTED}" >> "$GITHUB_OUTPUT" |
| 62 | +
|
28 | 63 | - name: "DCO Assistant" |
29 | | - if: (github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the DCO document and I hereby sign the DCO.') || github.event_name == 'pull_request_target' |
| 64 | + if: >- |
| 65 | + steps.trusted-agentic-ci.outputs.trusted != 'true' |
| 66 | + && ((github.event.comment.body == 'recheck' || github.event.comment.body == 'I have read the DCO document and I hereby sign the DCO.') || github.event_name == 'pull_request_target') |
30 | 67 | uses: contributor-assistant/github-action@ca4a40a7d1004f18d9960b404b97e5f30a505a08 |
31 | 68 | env: |
32 | 69 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
0 commit comments