diff --git a/.github/workflows/codex-gate.yml b/.github/workflows/codex-gate.yml deleted file mode 100644 index 6142646..0000000 --- a/.github/workflows/codex-gate.yml +++ /dev/null @@ -1,127 +0,0 @@ -name: Codex Review Gate - -# Watches for Codex reviews (submitted via FuugaMo's GitHub account). -# Sets the commit status codex/lgtm based on the review outcome. -# Also handles comment-based signals in case Codex posts a comment -# rather than a formal review state. - -on: - pull_request_review: - types: [submitted, dismissed] - issue_comment: - types: [created, edited] - -permissions: - statuses: write - pull-requests: read - -jobs: - gate: - runs-on: ubuntu-latest - steps: - - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const CODEX_USER = 'chatgpt-codex-connector'; - - // ── Resolve PR and commit SHA ────────────────────────────────────── - let pr, sha; - - if (context.eventName === 'pull_request_review') { - pr = context.payload.pull_request; - sha = pr.head.sha; - } else { - // issue_comment — only handle PR comments - if (!context.payload.issue.pull_request) return; - const { data } = await github.rest.pulls.get({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: context.payload.issue.number, - }); - pr = data; - sha = data.head.sha; - } - - // Only process PRs with the auto-fix label (from OpenClaw) - const labels = (pr.labels || []).map(l => l.name); - if (!labels.includes('auto-fix')) return; - - // ── Determine Codex verdict ──────────────────────────────────────── - let state = null; - let description = ''; - - if (context.eventName === 'pull_request_review') { - const review = context.payload.review; - if (review.user.login !== CODEX_USER) return; - - if (review.state === 'APPROVED') { - state = 'success'; - description = 'Codex LGTM — no critical issues'; - } else if (review.state === 'CHANGES_REQUESTED') { - state = 'failure'; - description = 'Codex requested changes'; - } else if (review.state === 'DISMISSED') { - state = 'pending'; - description = 'Codex review dismissed — awaiting re-review'; - } else { - // COMMENTED — parse the body for signals - const body = (review.body || '').toLowerCase(); - const critical = ['critical', 'p0', 'security issue', 'breaking', 'incorrect']; - const positive = ['lgtm', 'no issues', 'looks good', 'no critical', 'approved', "didn't find any", 'no major issues', 'hooray']; - if (critical.some(k => body.includes(k))) { - state = 'failure'; - description = 'Codex flagged critical issues'; - } else if (positive.some(k => body.includes(k))) { - state = 'success'; - description = 'Codex LGTM (via comment)'; - } - } - } else { - // issue_comment path — only care about comments from Codex/FuugaMo - const comment = context.payload.comment; - if (comment.user.login !== CODEX_USER) return; - const body = (comment.body || '').toLowerCase(); - const critical = ['critical', 'p0', 'security issue', 'breaking', 'incorrect']; - const positive = ['lgtm', 'no issues', 'looks good', 'no critical', 'approved', "didn't find any", 'no major issues', 'hooray']; - if (critical.some(k => body.includes(k))) { - state = 'failure'; - description = 'Codex flagged critical issues'; - } else if (positive.some(k => body.includes(k))) { - state = 'success'; - description = 'Codex LGTM (via comment)'; - } - } - - if (!state) return; // not enough signal to set a status - - // ── Set commit status ────────────────────────────────────────────── - await github.rest.repos.createCommitStatus({ - owner: context.repo.owner, - repo: context.repo.repo, - sha, - state, - description, - context: 'codex/lgtm', - }); - - // ── Enable auto-merge on the PR when Codex approves ─────────────── - if (state === 'success') { - try { - await github.rest.pulls.updateBranch({ - owner: context.repo.owner, - repo: context.repo.repo, - pull_number: pr.number, - }); - } catch (_) {} - - // Enable squash auto-merge (GitHub native) - await github.graphql(` - mutation($prId: ID!) { - enablePullRequestAutoMerge(input: { - pullRequestId: $prId, - mergeMethod: SQUASH - }) { clientMutationId } - } - `, { prId: pr.node_id }); - }