manual-approval/workflow_dispatcher.md
jaime merino 9e098fbb6e - Fixed Approver Expansion: Repaired the broken expandGroupFromUser function in approvers.go. It now correctly utilizes the Forgejo SDK to search for teams within an organization and expand them into individual users, while respecting the option to exclude the workflow initiator.
- Removed GitHub Dependencies: Excised the unused newGithubClient and its associated dependencies (google/go-github and oauth2) from main.go and go.mod.

   - Project Infrastructure Updates:
       - Updated Dockerfile to use golang:1.25 for consistency with go.mod.
       - Modified action.yaml to run from the local Dockerfile, ensuring that the Forgejo-specific logic is utilized.
   - Validation: Verified all changes through a successful build and by running the full test suite, all of which passed.
2026-04-22 15:28:23 +02:00

2.4 KiB

Forgejo Actions: Manual Approvals Guide

While StackitGit Actions does not currently 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.

Resource Efficiency (Cost Savings): Unlike workarounds that use third-party actions to poll for comments on an Issue, splitting workflows is significantly cheaper and more efficient. Pause-and-poll methods keep the original workflow active, holding the runner hostage and consuming compute minutes for hours or days while waiting for an approval. By splitting workflows, the runner is immediately freed after the build phase. A new runner is only provisioned when the deployment is explicitly approved.

Step 1: The Automated Build & 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: stackit-ubuntu-22
    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

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 Deploy
on:
  workflow_dispatch:
    inputs:
      version:
        description: 'Version or Branch to deploy'
        required: true
        default: 'main'

jobs:
  deploy:
    runs-on: stackit-ubuntu-22
    steps:
      - uses: actions/checkout@v4
        with:
          ref: ${{ github.event.inputs.version }}
      - name: Deploy to Production
        run: echo "Deploying version ${{ github.event.inputs.version }}..."

Workflow Execution

  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".