• Stars
    star
    373
  • Rank 113,930 (Top 3 %)
  • Language
    Go
  • License
    MIT License
  • Created over 2 years ago
  • Updated about 1 month ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Pause your GitHub Actions workflow and request manual approval from set approvers before continuing

Manual Workflow Approval

ci

Pause a GitHub Actions workflow and require manual approval from one or more approvers before continuing.

This is a very common feature for a deployment or release pipeline, and while this functionality is available from GitHub, it requires the use of environments and if you want to use this for private repositories then you need GitHub Enterprise. This action provides manual approval without the use of environments, and is freely available to use on private repositories.

Note: This approval duration is subject to the broader 72 hours timeout for a workflow. So keep that in mind when figuring out how quickly an approver must respond.

The way this action works is the following:

  1. Workflow comes to the manual-approval action.
  2. manual-approval will create an issue in the containing repository and assign it to the approvers.
  3. If and once all approvers respond with an approved keyword, the workflow will continue.
  4. If any of the approvers responds with a denied keyword, then the workflow will exit with a failed status.
  • Approval keywords - "approve", "approved", "lgtm", "yes"
  • Denied keywords - "deny", "denied", "no"

These are case insensitive with optional punctuation either a period or an exclamation mark.

In all cases, manual-approval will close the initial GitHub issue.

Usage

steps:
  - uses: trstringer/manual-approval@v1
    with:
      secret: ${{ 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
      additional-approved-words: ''
      additional-denied-words: ''
  • approvers is a comma-delimited list of all required approvers. An approver can either be a user or an org team. (Note: Required approvers must have the ability to be set as approvers in the repository. If you add an approver that doesn't have this permission then you would receive an HTTP/402 Validation Failed error when running this action)
  • minimum-approvals is an integer that sets the minimum number of approvals required to progress the workflow. Defaults to ALL approvers.
  • issue-title is a string that will be appended to the title of the issue.
  • issue-body is a string that will be prepended to the body of the issue.
  • exclude-workflow-initiator-as-approver is a boolean that indicates if the workflow initiator (determined by the GITHUB_ACTOR environment variable) should be filtered from the final list of approvers. This is optional and defaults to false. Set this to true to prevent users in the approvers list from being able to self-approve workflows.
  • additional-approved-words is a comma separated list of strings to expand the dictionary of words that indicate approval. This is optional and defaults to an empty string.
  • additional-denied-words is a comma separated list of strings to expand the dictionary of words that indicate denial. This is optional and defaults to an empty string.

Using Custom Words

GitHub has a rich library of emojis, and these all work in additional approved words or denied words. Some values GitHub will store in their text version - i.e. :shipit:. Other emojis, GitHub will store in their unicode emoji form, like . For a seamless experience, it is recommended that you add the custom words to a GitHub comment, and then copy it back out of the comment into your actions configuration yaml.

Org team approver

If you want to have approvers set to an org team, then you need to take a different approach. The default GitHub Actions automatic token does not have the necessary permissions to list out team members. If you would like to use this then you need to generate a token from a GitHub App with the correct set of permissions.

Create a GitHub App with read-only access to organization members. Once the app is created, add a repo secret with the app ID. In the GitHub App settings, generate a private key and add that as a secret in the repo as well. You can get the app token by using the tibdex/github-app-token GitHub Action:

Note: The GitHub App tokens expire after 1 hour which implies duration for the approval cannot exceed 60 minutes or the job will fail due to bad credentials. See docs.

jobs:
  myjob:
    runs-on: ubuntu-latest
    steps:
      - name: Generate token
        id: generate_token
        uses: tibdex/github-app-token@v1
        with:
          app_id: ${{ secrets.APP_ID }}
          private_key: ${{ secrets.APP_PRIVATE_KEY }}
      - name: Wait for approval
        uses: trstringer/manual-approval@v1
        with:
          secret: ${{ steps.generate_token.outputs.token }}
          approvers: myteam
          minimum-approvals: 1

Timeout

If you'd like to force a timeout of your workflow pause, you can specify timeout-minutes at either the step level or the job level.

For instance, if you want your manual approval step to timeout after an hour you could do the following:

steps:
  - uses: trstringer/manual-approval@v1
    timeout-minutes: 60
    ...

Permissions

For the action to create a new issue in your project, please ensure that the action has write permissions on issues. You may have to add the following to your workflow:

permissions:
  issues: write

For more information on permissions, please look at the GitHub documentation.

Limitations

  • While the workflow is paused, it will still continue to consume a concurrent job allocation out of the max concurrent jobs.
  • A job (including a paused job) will be failed after 6 hours.
  • A paused job is still running compute/instance/virtual machine and will continue to incur costs.

Development

Running test code

To test out your code in an action, you need to build the image and push it to a different container registry repository. For instance, if I want to test some code I won't build the image with the main image repository. Prior to this, comment out the label binding the image to a repo:

# LABEL org.opencontainers.image.source https://github.com/trstringer/manual-approval

Build the image:

$ VERSION=1.7.1-rc.1 make IMAGE_REPO=ghcr.io/trstringer/manual-approval-test build

Note: The image version can be whatever you want, as this image wouldn't be pushed to production. It is only for testing.

Push the image to your container registry:

$ VERSION=1.7.1-rc.1 make IMAGE_REPO=ghcr.io/trstringer/manual-approval-test push

To test out the image you will need to modify action.yaml so that it points to your new image that you're testing:

  image: docker://ghcr.io/trstringer/manual-approval-test:1.7.0-rc.1

Then to test out the image, run a workflow specifying your dev branch:

- name: Wait for approval
  uses: your-github-user/manual-approval@your-dev-branch
  with:
    secret: ${{ secrets.GITHUB_TOKEN }}
    approvers: trstringer

For uses, this should point to your repo and dev branch.

Note: To test out the action that uses an approver that is an org team, refer to the org team approver section for instructions.

Create a release

  1. Build the new version's image: $ VERSION=1.7.0 make build
  2. Push the new image: $ VERSION=1.7.0 make push
  3. Create a release branch and modify action.yaml to point to the new image
  4. Open and merge a PR to add these changes to the default branch
  5. Make sure to fetch the new changes into your local repo: $ git checkout main && git fetch origin && git merge origin main
  6. Delete the v1 tag locally and remotely: $ git tag -d v1 && git push --delete origin v1
  7. Create and push new tags: $ git tag v1.7.0 && git tag v1 && git push origin --tags
  8. Create the GitHub project release

More Repositories

1

awesome-tech-conferences

📢 A curated list of upcoming technical conferences
327
star
2

remote-jobs-hiring-without-whiteboards

💡 Intersection of the two famous lists for remote-jobs and hiring-without-whiteboards
Python
323
star
3

cli-debugging-cheatsheets

🔥 Collection of command-line debugging cheatsheets for multiple languages and runtimes
256
star
4

create-react-app-with-redux

🌟 Simple redux implementation added to an app created with create-react-app
JavaScript
159
star
5

ansible-dev-by-example

💥 Ansible module development with examples and walk-throughs
133
star
6

pycli

💻 Basic structure for a simple Python CLI
Python
110
star
7

otel-shopping-cart

Sample application illustrating multiple aspects of observability with OpenTelemetry
Go
83
star
8

k8s-controller-core-resource

Base sample for a custom controller in Kubernetes working with core resources
Go
82
star
9

k8s-controller-custom-resource

Base sample for a custom controller in Kubernetes working with custom resources
Go
62
star
10

electron-basic-ui-layout

🐙 Common UI layout for an Electron/React app
JavaScript
54
star
11

jersey

🍝 A to-do/backlog CLI with Trello for a backend
Python
41
star
12

azblogfilter

Retrieve Azure blog update posts with the capability to filter on keywords in the title or categories of posts. Allows for easy automation!
Go
28
star
13

electron-flexbox-ui-layout

🐳 Common UI layout for an Electron/React app using Flexbox
JavaScript
26
star
14

go-systemd-time

📅 Go implementation of systemd relative time adjustments
Go
23
star
15

az-aks-ssh

SSH into Azure Kubernetes Service (AKS) nodes
Shell
22
star
16

react-laboratory

🔬 Minimal boilerplate to experiment and test with React without having to worry about the server
JavaScript
21
star
17

redditwatcher

📻 Reddit streaming CLI
Shell
19
star
18

python-flask-docker-compose-debugging

🐛 Sample application to help illustrate how to break into the debugger in a Python Flask application running as a container in Docker Compose
Python
18
star
19

kubernetes-mutating-webhook

Example showing how to implement a basic mutating webhook
Go
17
star
20

verpy

🐍 Python application versioning tool
Python
15
star
21

az-consumption-summary

Azure consumption summary and reporting for the terminal
Python
13
star
22

jwt-creator

Utility to quickly and easily create and verify JSON web tokens (JWT)
Go
13
star
23

pipin

🍓 Raspberry Pi pin controller CLI
JavaScript
12
star
24

pymail

📬 Command-line email client
Python
12
star
25

sherlock

☁️ Integration testing sandbox environment provisioning tool for Microsoft Azure
JavaScript
12
star
26

vscode-tips

💡 Visual Studio Code tips and quick reference
12
star
27

kubectl-example

kubectl plugin to dump example helper resource templates
Go
12
star
28

linux-core-temperature-monitor

🔥 Script (meant to run via cron) to monitor, log, and alert when the CPU is throttled due to overheating
Python
11
star
29

psql.nvim

Plugin to work with PostgreSQL directly from Neovim
Lua
10
star
30

venvdetect

🐍 Detect available Python virtual environments in your current directory
Python
9
star
31

terraform-azure-linux-vm

🐧 Provision an Azure Linux VM with Terraform
HCL
9
star
32

boiler-room-custodian

🐅 mop up those boilerplates
JavaScript
8
star
33

python3-random-quote

Python
6
star
34

kubernetes-aad-msi

Authenticate Kubernetes applications to cloud resources with Azure Active Directory
Go
6
star
35

pywave

🌊 CLI to fetch and parse buoy data
Python
6
star
36

shark-mail

🐟 Filesystem-based email CLI
JavaScript
5
star
37

tweetify

🐦 Node.js module that formats text to tweet
JavaScript
4
star
38

kubernetes-validating-webhook

Example showing how to implement a basic Kubernetes validating webhook
Go
4
star
39

trstringer.github.io

Build a Jekyll blog in minutes, without touching the command line.
SCSS
3
star
40

peachy-cli

🍑 CLI for cross-platform and cross-data-source querying and data manipulation
JavaScript
3
star
41

stackoverflow-digest

Get a digest of StackOverflow questions.
Python
2
star
42

go-template-cli-simple

Go template for a simple CLI
Go
2
star
43

require-label-prefix

GitHub Action to either warn or add a default label when no label with a prefix exists on an issue
Go
2
star
44

kuberetes-log-dump

Dump all Kubernetes pod logs (current and previous)
Shell
2
star
45

aks-deploy-from-github-actions

Example showing how to deploy to AKS (Azure Kubernetes Service) from GitHub Actions
Makefile
2
star
46

az-cli-helpers

Wrapper shell functions to make Azure resource management easier
Shell
2
star
47

azure-logger

📘 Node.js module that makes logging to Azure extremely easy
JavaScript
2
star
48

pyllo-world

Hello world with CI
Python
2
star
49

psqlcm

Local connection manager for PostgreSQL
Go
2
star
50

surfchartdl

🌊 Surf chart downloader
Python
2
star
51

platform-chaos-fn-startstop

azure-chaos extension to trigger start/stop events against an Azure web app
JavaScript
2
star
52

stocks-cli

💰 Stock price lookup CLI
JavaScript
2
star
53

sql-log-shipping

Utility for log shipping within SQL Server
PowerShell
1
star
54

pip-requirements

Wrapper shell functions for auto-creating Python dependency requirements files based on environment
1
star
55

trstringer

1
star
56

tstringer.github.io

🏄 My blog
CSS
1
star
57

char-art

💻 Making character art has never been easier!
JavaScript
1
star
58

nodejs-101-presentation

🚀 Slide deck for an introduction to Node.js and JavaScript
JavaScript
1
star
59

discuss-this

🌇 Node.js application/API for wordly discussions
JavaScript
1
star
60

sorting-algorithm-stability

Demo application highlighting sorting algorithm stability output
Go
1
star
61

sql-server-versions-powershell

PowerShell Module to consume the SQL Server Versions API
PowerShell
1
star
62

k8s-prometheus-grafana-dashboard-deployment

Shell
1
star
63

cloud-init-update

Cloud-init update process.
Python
1
star
64

xevents-helper

Helper website to assist with constructing Extended Events sessions for SQL Server
C#
1
star
65

discuss-this-web-job

⏰ The web job in charge of handling the routine discuss this calls
JavaScript
1
star
66

trill

🐤 Easily and quickly tweet long and short tweets with flexibility
JavaScript
1
star
67

peacherine

🍑 Cross-platform (node.js) and multi-datasource query module
JavaScript
1
star
68

pywave2

🌊 Get swell buoy data
Python
1
star
69

cicd-basics

JavaScript
1
star
70

httpbin2

Web server for testing, demo'ing, learning, and many other uses. Great for microservice environments and more!
Go
1
star