How to Manage Manual Workflow Approval in GitHub Actions

Jul 20, 2022 | Programming

Continuous Integration and Continuous Deployment (CI/CD) pipelines often require a level of scrutiny before proceeding to the next step, especially vital for deployments and releases. In GitHub Actions, you can implement a manual approval checkpoint when following deployment workflows. This guide outlines how to set up manual approval for your workflows effectively.

What is Manual Workflow Approval?

Manual workflow approval is a feature that allows you to pause a workflow and await approval from designated users before continuing. It acts like a bouncer at an exclusive club, ensuring that only the right individuals grant permission for the party (workflow) to continue.

Step-by-Step Guide to Implementing Manual Approval

  • 1. Define Your Workflow
    You’ll begin by specifying your workflow within a YAML file. Here’s a simplified example of how your `.yaml` configuration might look:
  • yaml
        steps:
          - uses: trstringermanual-approval@v1
            with:
              secret: ${{ secrets.GITHUB_TOKEN }}
              approvers: user1,user2,org-team1
              minimum-approvals: 1
              issue-title: Deploying v1.3.5 to prod from staging
              issue-body: Please approve or deny the deployment of version v1.3.5.
              exclude-workflow-initiator-as-approver: false
        
  • 2. Work with Approval and Denial Keywords
    Similar to how a guest list might have specified names for entry, you can establish keywords for approvals and denials:
    • Approval Keywords: approve, approved, lgtm, yes
    • Denied Keywords: deny, denied, no
  • 3. Handle Timeouts
    Just like your meeting invitation will expire after a certain time, you might want to implement a timeout within your workflow. You can set a timeout duration to force completion if an approval isn’t received promptly:
  • yaml
        steps:
          - uses: trstringermanual-approval@v1
            timeout-minutes: 60
        

Using Custom Approval Words

If you want your approvers to express their approval in more colorful ways, GitHub Actions allows you to leverage emojis in approval or denial keywords. For instance, if someone declares “:shipit:” or “🚀”, it can count as an approval!

Testing Your Setup

Before rolling out your approvals in production, it’s critical to test your setup. You should be sure that everything runs smoothly by running your workflows on a test branch with appropriate tokens and configurations.

Troubleshooting Common Issues

  • If you encounter an error stating HTTP402 Validation Failed, verify that the users you are trying to include as approvers have appropriate permissions in the repository.
  • If you’re using an organization team, ensure that your GitHub App has the correct permissions set to access organization members — particularly **read-only access to organization members**.
  • Remember that if approvals take too long, workflows may be paused indefinitely, leading to extra costs. Never exceed the maximum limits stated in GitHub Actions.
  • For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

Manual workflow approval in GitHub Actions is a powerful feature that can enhance the security and integrity of your deployment processes. With the guidance provided above, you can easily set this up within your project.

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox