Deploy, promote and roll back
Goal
QA deploys a work item to staging from Jira. When the deploy finishes, the work item offers two next steps: Roll back staging for the people who deploy, and Promote to production for release managers only. After a production deploy, only Roll back production is offered.
It's a Jira deploy button with guard rails: release managers approve deployment from Jira by pressing Promote to production, and nobody else sees that button enabled.
What you need
- Cuelight installed and GitHub connected (Getting started)
- Jira groups
qa-team,developersandrelease-managers - Two workflows:
deploy.ymlandrollback.ymlon the default branch
Actions
[
{
"id": "deploy-staging",
"label": "Deploy to staging",
"style": "primary",
"type": "github_workflow",
"github": {
"workflow": "deploy.yml",
"inputs": {
"environment": "staging",
"issue_key": "{{issue.key}}",
"reason": "{{input.reason}}"
}
},
"form": [{ "name": "reason", "label": "Reason", "type": "textarea", "maxLength": 300 }],
"showWhen": { "statuses": ["In Review"] },
"allow": { "groups": ["qa-team", "developers"] }
},
{
"id": "rollback-staging",
"label": "Roll back staging",
"style": "danger",
"type": "github_workflow",
"availability": "next-only",
"github": {
"workflow": "rollback.yml",
"inputs": { "environment": "staging", "issue_key": "{{issue.key}}" }
},
"allow": { "groups": ["developers", "release-managers"] }
},
{
"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"] }
},
{
"id": "rollback-production",
"label": "Roll back production",
"style": "danger",
"type": "github_workflow",
"availability": "next-only",
"github": {
"workflow": "rollback.yml",
"inputs": { "environment": "production", "issue_key": "{{issue.key}}" }
},
"allow": { "groups": ["release-managers"] }
}
]Only Deploy to staging shows from rules. The other three are next-only, so they appear only
when a deploy offers them.
Workflow
deploy.yml picks the next steps from the environment it deployed to:
name: Deploy
on:
workflow_dispatch:
inputs:
environment: { type: string, required: true }
issue_key: { type: string, required: true }
reason: { type: string, required: false }
cuelight_callback_url: { type: string, required: false }
cuelight_token: { type: string, required: false }
permissions:
contents: read
jobs:
deploy:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
steps:
- uses: actions/checkout@v7
- name: Deploy
env:
ENVIRONMENT: ${{ inputs.environment }}
run: ./scripts/deploy.sh "$ENVIRONMENT"
- name: Pick the next steps
id: next
env:
ENVIRONMENT: ${{ inputs.environment }}
run: |
case "$ENVIRONMENT" in
staging) echo "next=rollback-staging,promote-production" >>"$GITHUB_OUTPUT" ;;
production) echo "next=rollback-production" >>"$GITHUB_OUTPUT" ;;
esac
- name: Hand back the next step
if: always()
uses: huseyinbuyukdere/cuelight-report@v1
with:
status: ${{ job.status }}
message: Deployed ${{ github.sha }} to ${{ inputs.environment }}
next: ${{ steps.next.outputs.next }}rollback.yml has the same inputs, runs your rollback script and reports without next:
- name: Hand back the result
if: always()
uses: huseyinbuyukdere/cuelight-report@v1
with:
status: ${{ job.status }}
message: Rolled back ${{ inputs.environment }}If the deploy fails, next is still sent. Remove it on failure if you'd rather offer nothing, for
example with next: ${{ job.status == 'success' && steps.next.outputs.next || '' }}.
What people see
- Ayşe from QA opens SHOP-142 in In Review and presses Deploy to staging with the reason
"QA pass 2". The work item gets a comment:
▶ Deploy to staging started by Ayşe Kaya. Inputs: environment=staging, issue_key=SHOP-142, reason="QA pass 2" - About two minutes later the lamp turns green:
✓ Deploy to staging succeeded in 2m 14s. - The panel shows Roll back staging and Promote to production, "Suggested by deploy.yml". Ayşe sees Promote disabled: "Only members of Release Managers can run this."
- Deniz, a release manager, presses Promote to production, enters a reason and confirms "Run "Promote to production" on SHOP-142?". The panel then offers only Roll back production.
Variations
- GitHub environments. The
environment:line lets GitHub's own protection rules, like required reviewers, apply on top of Cuelight's group check. - Pre-fill the reason. Send
next: '[{"action":"promote-production","inputs":{"reason":"Staging verified"}}]'to fill the form in advance. - Shorter window. Add
expires-in-hours: 24so Promote disappears if nobody acts within a day.