From c9de37e14be67cdbd0688450fcd9b48c932c7b77 Mon Sep 17 00:00:00 2001 From: Thomas Stringer Date: Fri, 25 Mar 2022 21:28:51 -0400 Subject: [PATCH] add workflow and readme --- .github/workflows/ci.yaml | 24 ++++++++++++++++++++++++ Makefile | 21 +++++++++++++++++++++ README.md | 29 +++++++++++++++++++++++++++-- 3 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/ci.yaml create mode 100644 Makefile diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..b5e32bb --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,24 @@ +name: CI + +on: + workflow_dispatch + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + ci: + name: CI + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Build + run: make build + env: + VERSION: latest + - name: Test + run: make test diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..3aadb49 --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +IMAGE_REPO=ghcr.io/trstringer/manual-approval + +.PHONY: build +build: + @if [ -z "$$VERSION" ]; then \ + echo "VERSION is required"; \ + exit 1; \ + fi + docker build -t $(IMAGE_REPO):$$VERSION . + +.PHONY: push +push: + @if [ -z "$$VERSION" ]; then \ + echo "VERSION is required"; \ + exit 1; \ + fi + docker push $(IMAGE_REPO):$$VERSION + +.PHONY: test +test: + go test -v . diff --git a/README.md b/README.md index bdead4f..c08e604 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,28 @@ -# GitHub Actions Manual Workflow Approval +# Manual Workflow Approval -Add this action to your workflow to get manual approval to continue. +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](https://docs.github.com/en/actions/managing-workflow-runs/reviewing-deployments), 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. +1. `manual-approval` will create an issue in the containing repository and assign it to the `approvers`. +1. If and once all approvers respond with "Approved", the workflow will continue. +1. If any of the approvers responds with "Denied", then the workflow will exit with a failed status. + +In all cases, `manual-approval` will close the initial GitHub issue. + +## Usage + +```yaml +steps: + - uses: trstringer/manual-approval@v1 + with: + secret: ${{ github.TOKEN }} + approvers: user1,user2 +``` + +`approvers` is a comma-delimited list of all required approvers.