Skip to content

Split Workflow

Last updated on

While Actions does not feature native environment protection rules that pause a running workflow for a UI approval, the most effective and resource-efficient workaround is to split your CI/CD pipeline into separate workflows using the workflow_dispatch event.

Step 1: The automated build and test workflow

Section titled “Step 1: The automated build and test workflow”

Create your primary workflow that runs automatically on every push or pull request. This workflow handles everything up to the point of deployment.

name: 1. Build and Test
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Run tests
run: echo "Testing the code..."
- name: Build artifact
run: echo "Building artifact..."
# Upload artifacts here for the deploy workflow to download

Create a second workflow triggered only by workflow_dispatch. This generates a “Run Workflow” button in the Forgejo UI, serving as your manual approval gate.

name: 2. Manual Production Deploy
on:
workflow_dispatch:
inputs:
version:
description: "Version or Branch to deploy"
required: true
default: "main"
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.version }}
- name: Deploy to Production
run: echo "Deploying version ${{ github.event.inputs.version }}..."
  1. A developer pushes code, triggering the Build and Test workflow automatically.
  2. The team reviews the workflow results and test logs. The runner completes its job, reports success, and shuts down.
  3. When the release is approved, an authorized team member navigates to the Forgejo Actions tab, selects the Manual Production Deploy workflow, and clicks “Run Workflow”.