|
| 1 | +# This file is managed by fullsend. Do not edit it directly. |
| 2 | +# Upstream: https://github.com/fullsend-ai/fullsend/blob/main/internal/scaffold/fullsend-repo/.github/workflows/fullsend.yaml |
| 3 | +--- |
| 4 | +# fullsend shim workflow (per-repo installation mode) |
| 5 | +# Routes events to agent workflows via reusable-dispatch.yml. |
| 6 | +# All agent execution happens in this repository's context. |
| 7 | +# |
| 8 | +# Security: pull_request_target runs the BASE branch version of this workflow, |
| 9 | +# preventing PRs from modifying it to exfiltrate credentials. |
| 10 | +# This shim never checks out PR code, so it is not vulnerable to "pwn request" |
| 11 | +# attacks. |
| 12 | +# |
| 13 | +# Routing: this shim forwards the raw event context to reusable-dispatch.yml, |
| 14 | +# which determines the stage and runs the agent inline (ADR 62). |
| 15 | +# Adding a new stage requires only a job in reusable-dispatch.yml — zero changes to this repo. |
| 16 | +# |
| 17 | +# Concurrency: per-role cancel-in-progress groups live in reusable-dispatch.yml |
| 18 | +# stage jobs with -agent- suffix. Roles operate independently (#2452). |
| 19 | +name: fullsend |
| 20 | + |
| 21 | +on: |
| 22 | + issues: |
| 23 | + types: [opened, edited, labeled] |
| 24 | + issue_comment: |
| 25 | + types: [created] |
| 26 | + pull_request_target: |
| 27 | + types: [opened, synchronize, ready_for_review, closed, labeled, unlabeled] |
| 28 | + pull_request_review: |
| 29 | + types: [submitted] |
| 30 | + |
| 31 | +permissions: {} |
| 32 | + |
| 33 | +jobs: |
| 34 | + dispatch: |
| 35 | + if: >- |
| 36 | + (github.event_name != 'pull_request_target' && github.event_name != 'pull_request_review' |
| 37 | + || github.event.pull_request.head.ref != 'fullsend/scaffold-install') |
| 38 | + && (github.event_name != 'issue_comment' |
| 39 | + || startsWith(github.event.comment.body, '/fs-')) |
| 40 | + permissions: |
| 41 | + actions: write |
| 42 | + id-token: write |
| 43 | + contents: write |
| 44 | + issues: write |
| 45 | + packages: read |
| 46 | + pull-requests: write |
| 47 | + uses: fullsend-ai/fullsend/.github/workflows/reusable-dispatch.yml@v0.56.1 |
| 48 | + with: |
| 49 | + event_action: ${{ github.event.action }} |
| 50 | + mint_url: ${{ vars.FULLSEND_MINT_URL }} |
| 51 | + gcp_region: ${{ vars.FULLSEND_GCP_REGION }} |
| 52 | + project_number: ${{ vars.FULLSEND_PROJECT_NUMBER }} |
| 53 | + runner_image: ubuntu-24.04 |
| 54 | + secrets: |
| 55 | + FULLSEND_GCP_WIF_PROVIDER: ${{ secrets.FULLSEND_GCP_WIF_PROVIDER }} |
| 56 | + FULLSEND_GCP_PROJECT_ID: ${{ secrets.FULLSEND_GCP_PROJECT_ID }} |
| 57 | + FULLSEND_OPENAI_API_KEY: ${{ secrets.FULLSEND_OPENAI_API_KEY }} |
| 58 | + FULLSEND_INFERENCE_GATEWAY_API_KEY: ${{ secrets.FULLSEND_INFERENCE_GATEWAY_API_KEY }} |
| 59 | + OTEL_EXPORTER_OTLP_TRACES_HEADERS: ${{ secrets.OTEL_EXPORTER_OTLP_TRACES_HEADERS }} |
| 60 | + OTEL_EXPORTER_OTLP_HEADERS: ${{ secrets.OTEL_EXPORTER_OTLP_HEADERS }} |
| 61 | + FULLSEND_JIRA_TOKEN: ${{ secrets.FULLSEND_JIRA_TOKEN }} |
| 62 | + FULLSEND_JIRA_EMAIL: ${{ secrets.FULLSEND_JIRA_EMAIL }} |
| 63 | + FULLSEND_JIRA_CLIENT_ID: ${{ secrets.FULLSEND_JIRA_CLIENT_ID }} |
| 64 | + FULLSEND_JIRA_CLIENT_SECRET: ${{ secrets.FULLSEND_JIRA_CLIENT_SECRET }} |
| 65 | + FULLSEND_GITHUB_RUNNER_SECRETS: ${{ secrets.FULLSEND_GITHUB_RUNNER_SECRETS }} |
| 66 | + |
| 67 | + stop-fix: |
| 68 | + # Job-level if: is intentionally coarse — it only screens for the |
| 69 | + # /fs-fix-stop command on a PR from a non-bot. The authoritative |
| 70 | + # authorization decision (collaborator permission API + PR-author escape |
| 71 | + # hatch) is made in the step below, so a maintainer whose author_association |
| 72 | + # is not MEMBER (e.g. private org membership) is not filtered out (ADR 0054). |
| 73 | + if: >- |
| 74 | + github.event_name == 'issue_comment' |
| 75 | + && github.event.issue.pull_request |
| 76 | + && github.event.comment.user.type != 'Bot' |
| 77 | + && github.event.comment.body == '/fs-fix-stop' |
| 78 | + runs-on: ubuntu-24.04 |
| 79 | + permissions: |
| 80 | + contents: read |
| 81 | + issues: write |
| 82 | + pull-requests: write |
| 83 | + steps: |
| 84 | + - name: Add fullsend-no-fix label and notify |
| 85 | + env: |
| 86 | + GH_TOKEN: ${{ github.token }} |
| 87 | + PR_NUMBER: ${{ github.event.issue.number }} |
| 88 | + REPO: ${{ github.repository }} |
| 89 | + COMMENT_USER_LOGIN: ${{ github.event.comment.user.login }} |
| 90 | + ISSUE_USER_LOGIN: ${{ github.event.issue.user.login }} |
| 91 | + run: | |
| 92 | + set -euo pipefail |
| 93 | + # ADR 0054: authorize via the collaborator permission API |
| 94 | + # (admin|maintain|write), not author_association — the latter grants |
| 95 | + # contributor status to anyone with a single merged PR (issue #5421). |
| 96 | + # Mirrors has_repo_permission() in reusable-dispatch.yml, including the |
| 97 | + # custom-role --jq resolution; keep the two in sync. |
| 98 | + # The PR author may always stop the fix agent on their own PR. |
| 99 | + authorized=false |
| 100 | + if [[ -n "$COMMENT_USER_LOGIN" && "$COMMENT_USER_LOGIN" == "$ISSUE_USER_LOGIN" ]]; then |
| 101 | + authorized=true |
| 102 | + else |
| 103 | + if api_err=$(mktemp); then |
| 104 | + # $p is a jq variable; the single quotes are intentional. |
| 105 | + # shellcheck disable=SC2016 |
| 106 | + if role=$(gh api "repos/$REPO/collaborators/$COMMENT_USER_LOGIN/permission" \ |
| 107 | + --jq '.user.permissions as $p |
| 108 | + | if (.role_name | type) != "string" or .role_name == "" then "none" |
| 109 | + elif (.role_name | IN("admin", "maintain", "write", "triage", "read")) then .role_name |
| 110 | + elif $p == null then |
| 111 | + if (.permission | IN("admin", "write", "read")) then .permission else "none" end |
| 112 | + elif ($p | type) == "object" then |
| 113 | + if $p.admin == true then "admin" |
| 114 | + elif $p.maintain == true then "maintain" |
| 115 | + elif $p.push == true then "write" |
| 116 | + elif $p.triage == true then "triage" |
| 117 | + elif $p.pull == true then "read" |
| 118 | + else "none" end |
| 119 | + else "none" end' 2>"$api_err"); then |
| 120 | + case "$role" in |
| 121 | + admin|maintain|write) authorized=true ;; |
| 122 | + esac |
| 123 | + else |
| 124 | + echo "::warning::Permission API call failed for $COMMENT_USER_LOGIN: $(cat "$api_err")" |
| 125 | + fi |
| 126 | + rm -f "$api_err" |
| 127 | + else |
| 128 | + echo "::warning::Failed to create temp file for permission check of $COMMENT_USER_LOGIN" |
| 129 | + fi |
| 130 | + fi |
| 131 | + if [[ "$authorized" != "true" ]]; then |
| 132 | + echo "::notice::User $COMMENT_USER_LOGIN is not authorized to stop the fix agent (requires write access or PR authorship)" |
| 133 | + exit 0 |
| 134 | + fi |
| 135 | + gh label create "fullsend-no-fix" --repo "$REPO" \ |
| 136 | + --description "Skip bot-triggered fix agent runs" --color "FBCA04" \ |
| 137 | + 2>/dev/null || true |
| 138 | + gh pr edit "$PR_NUMBER" --repo "$REPO" \ |
| 139 | + --add-label "fullsend-no-fix" |
| 140 | + gh pr comment "$PR_NUMBER" --repo "$REPO" \ |
| 141 | + --body "Fix agent disabled for this PR. Remove the \`fullsend-no-fix\` label or use \`/fs-fix\` to re-engage." |
0 commit comments