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 Teston: [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 downloadStep 2: The manual deployment workflow
Section titled “Step 2: The manual deployment workflow”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 Deployon: 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 }}..."Running of the workflow
Section titled “Running of the workflow”- A developer pushes code, triggering the Build and Test workflow automatically.
- The team reviews the workflow results and test logs. The runner completes its job, reports success, and shuts down.
- 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”.