Approve after an agent's pull request

Goal

An AI agent, or a person, opens a pull request for a work item. The pull request's workflow offers Deploy preview on the work item. QA deploys the preview from Jira, and the preview's result offers Promote to production to release managers. Nobody needs to know who opened the pull request or to leave Jira.

What you need

  • Cuelight installed and GitHub connected
  • Branch names that contain the work item key, like SHOP-142-fix-saved-card. Most agents and Jira's "Create branch" do this.
  • Repository secrets CUELIGHT_REPORT_URL and CUELIGHT_INSTALL_KEY, both from Cuelight settings → Reporting
  • The deploy.yml workflow from Deploy, promote and roll back

Actions

[
  {
    "id": "deploy-preview",
    "label": "Deploy preview",
    "type": "github_workflow",
    "availability": "next-only",
    "github": {
      "workflow": "deploy.yml",
      "inputs": { "environment": "preview", "issue_key": "{{issue.key}}", "pr": "{{input.pr}}" }
    },
    "form": [{ "name": "pr", "label": "Pull request", "type": "text", "required": true }],
    "allow": { "groups": ["qa-team", "developers"] }
  },
  {
    "id": "promote-production",
    "label": "Promote to production",
    "style": "primary",
    "confirm": true,
    "type": "github_workflow",
    "availability": "next-only",
    "github": {
      "workflow": "deploy.yml",
      "inputs": {
        "environment": "production",
        "issue_key": "{{issue.key}}",
        "reason": "{{input.reason}}"
      }
    },
    "form": [
      {
        "name": "reason",
        "label": "Reason",
        "type": "textarea",
        "required": true,
        "maxLength": 300
      }
    ],
    "allow": { "groups": ["release-managers"] }
  }
]

workflow_dispatch runs on a branch or tag, so the pull request number goes in as an input. Add pr: { type: string, required: false } to deploy.yml, and have the preview step fetch refs/pull/$PR/head before deploying.

Workflow

pr-offer.yml runs when a pull request opens:

name: Offer a preview
on:
  pull_request:
    types: [opened, reopened]

permissions:
  contents: read

jobs:
  offer:
    runs-on: ubuntu-latest
    # Secrets aren't available to pull requests from forks.
    if: github.event.pull_request.head.repo.full_name == github.repository
    steps:
      - name: Find the work item key
        id: key
        env:
          BRANCH: ${{ github.head_ref }}
        run: |
          key="$(printf '%s' "$BRANCH" | grep -oE '[A-Z][A-Z0-9]+-[0-9]+' | head -n1 || true)"
          echo "key=$key" >>"$GITHUB_OUTPUT"
      - name: Offer a preview deploy
        if: steps.key.outputs.key != ''
        uses: huseyinbuyukdere/cuelight-report@v1
        env:
          CUELIGHT_REPORT_URL: ${{ secrets.CUELIGHT_REPORT_URL }}
        with:
          install-key: ${{ secrets.CUELIGHT_INSTALL_KEY }}
          issue-key: ${{ steps.key.outputs.key }}
          source: 'PR #${{ github.event.pull_request.number }}'
          message: Preview is ready to deploy
          next: '[{"action":"deploy-preview","inputs":{"pr":"${{ github.event.pull_request.number }}"}}]'
          expires-in-hours: '72'

In deploy.yml, offer Promote after a successful preview:

case "$ENVIRONMENT" in
preview) echo "next=promote-production" >>"$GITHUB_OUTPUT" ;;
staging) echo "next=rollback-staging,promote-production" >>"$GITHUB_OUTPUT" ;;
production) echo "next=rollback-production" >>"$GITHUB_OUTPUT" ;;
esac

What people see

  1. An agent opens PR #12 from SHOP-142-fix-saved-card. Within a minute SHOP-142 shows Deploy preview, "Suggested by PR #12", with the message "Preview is ready to deploy".
  2. QA presses it. The form already says 12. The preview deploys, and the work item gets a start and a finish comment.
  3. The panel offers Promote to production, "Suggested by deploy.yml". Only release managers can press it; everyone else sees why not.

Variations

  • Test the preview before Promote. Test the preview with AI offers AI-written tests after the preview, and only a passing run offers Promote to production.
  • Start the agent from Jira too. Run Claude Code or Codex from Jira adds a Send to agent button, and its workflow offers Deploy preview itself.
  • Agents that call HTTP directly. An agent can send the same offer with one request; see Offer a next step from any tool.
  • Only for some work item types. The offer can't check rules, so filter in the workflow, or let the release managers' group decide.
  • Re-offer on new commits. Add synchronize to types. The same offer refreshes instead of piling up.