Skip to content

Rollback

Rollback #488

# AUTO-GENERATED by cascade - DO NOT EDIT MANUALLY
# Regenerate with: cascade generate-workflow --config .github/manifest.yaml
#
# Manual rollback: re-deploy a prior version or SHA to an environment.
#
# A read-only preflight resolves the target (from live state, the
# deploy-history ring, or manifest history), the deploy stage re-runs the
# configured deploy callbacks keyed on the resolved SHA, and finalize writes
# the rolled-back state back to trunk, marking the environment diverged until
# a forward promotion rejoins it.
name: Rollback
on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to roll back'
required: true
type: choice
options:
- test
- staging
- prod
target:
description: 'Prior version or SHA (optional; defaults to the previous version)'
required: false
type: string
default: ''
deployable:
description: 'Limit rollback to one deployable (optional)'
required: false
type: string
default: ''
dry_run:
description: 'Resolve and print without deploying'
required: false
type: boolean
default: false
permissions:
contents: read
concurrency:
group: "${{ github.workflow }}"
cancel-in-progress: false
jobs:
preflight:
name: Pre-flight Check
runs-on: ubuntu-latest
outputs:
target_env: ${{ steps.preflight.outputs.target_env }}
target_sha: ${{ steps.preflight.outputs.target_sha }}
target_version: ${{ steps.preflight.outputs.target_version }}
target_source: ${{ steps.preflight.outputs.target_source }}
can_proceed: ${{ steps.preflight.outputs.can_proceed }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
fetch-depth: 0
- name: Setup CLI
uses: stablekernel/cascade/.github/actions/setup-cli@3742e04377b952a263bb48a0a0bb5905c253d603 # v1.1.2-rc.0
with:
token: ${{ secrets.CASCADE_STATE_TOKEN }}
version: v1.1.2-rc.0
- name: Resolve Target
id: preflight
env:
ENVIRONMENT: ${{ github.event.inputs.environment }}
TARGET: ${{ github.event.inputs.target }}
DEPLOYABLE: ${{ github.event.inputs.deployable }}
run: |
cascade rollback preflight \
--config .github/manifest.yaml \
--env "$ENVIRONMENT" \
--to "$TARGET" \
--deployable "$DEPLOYABLE" \
--gha-output
- name: Fail if Cannot Proceed
if: steps.preflight.outputs.can_proceed == 'false'
run: exit 1
- name: Report Resolved Source
run: echo "rollback resolved from ${{ steps.preflight.outputs.target_source }}"
deploy-app:
name: Deploy app
needs: [preflight]
if: ${{ github.event.inputs.dry_run != 'true' && (github.event.inputs.deployable == '' || github.event.inputs.deployable == 'app') }}
uses: ./.github/workflows/deploy-app.yaml
with:
environment: ${{ needs.preflight.outputs.target_env }}
sha: ${{ needs.preflight.outputs.target_sha }}
finalize:
name: Finalize
needs: [preflight, deploy-app]
if: always() && needs.preflight.result == 'success' && github.event.inputs.dry_run != 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10
with:
fetch-depth: 0
- name: Setup CLI
uses: stablekernel/cascade/.github/actions/setup-cli@3742e04377b952a263bb48a0a0bb5905c253d603 # v1.1.2-rc.0
with:
token: ${{ secrets.CASCADE_STATE_TOKEN }}
version: v1.1.2-rc.0
- name: Finalize Rollback
env:
GH_TOKEN: ${{ secrets.CASCADE_STATE_TOKEN }}
GITHUB_TOKEN: ${{ secrets.CASCADE_STATE_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
DEPLOYABLE: ${{ github.event.inputs.deployable }}
DEPLOY_RESULT_APP: ${{ needs.deploy-app.result }}
run: |
cascade rollback finalize \
--config .github/manifest.yaml \
--env "${{ needs.preflight.outputs.target_env }}" \
--to "${{ needs.preflight.outputs.target_sha }}" \
--deployable "$DEPLOYABLE" \
--commit-push