Coder Social home page Coder Social logo

trstringer / manual-approval Goto Github PK

View Code? Open in Web Editor NEW
314.0 5.0 80.0 71 KB

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

License: MIT License

Dockerfile 1.11% Go 97.17% Makefile 1.71%
devops release release-automation deployment actions workflow release-management github github-actions workflows

manual-approval's Introduction

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

manual-approval's People

Contributors

augustomelo avatar bwvolleyball avatar dameonsmith avatar flasheh avatar gonzolino avatar sielaq avatar timorthi avatar troywitthoeft avatar trstringer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

manual-approval's Issues

Issue to approve/decline is not closed automatically

We are using the action with those props:

- uses: trstringer/manual-approval@v1
  with:
      secret: ...
      approvers: ...
      issue-title: ...

but after a job is declined I expect the issue should be closed automatically if there were no reaction. Unfortunately, some of them are not closed.

What might be the issue?

Thank you!

Unexpected input(s): 'timeout-minutes'?

Unexpected input(s) 'timeout-minutes', valid inputs are ['entryPoint', 'args', 'approvers', 'secret', 'minimum-approvals', 'issue-title']

Timeout argument is not recognised in GitHub Actions.

  - uses: trstringer/manual-approval@v1
    with:
       timeout-minutes: 5

Also, see #47.

Suspended User in a org team fails to create Issue in GHE

Example Config

steps:
  - uses: trstringer/manual-approval@v1
    with:
      approvers: org-team1

If there is a suspended user in your GitHub Enterprise org-team1, the action will fail with the following error message.

Error Message

Respond "approved", "approve", "lgtm", "yes" to continue workflow or "denied", "deny", "no" to cancel.
error creating issue: POST https://ghe.nsa.gov/api/v3/repos/noforn/turbulence/issues: 422 Validation Failed [{Resource:Issue Field:assignees Code:invalid Message:}]
##[debug]Docker Action run completed with exit code 1
##[debug]Finishing: Run trstringer/manual-approval@v1

Have some steps output as a comment

Add a new field named "comment" where the bot would add the output of a defined step as a comment.
This would happen before replying with yes/no for approvals.

For example,
A worflow does some tflinting and the approver wants to see tflint output and "terraform plan" output before allowing the workflow to proceed with the "terraform apply".

After an issue times out, next PRs could not trigger workflow run

Hi!

I have a workflow that runs on PR to branch master.

It was working well until an issue times out automatically (72 hrs). After that, following PRs do not trigger any workflow run. Even after I closed the issue myself (because of #30), following PRs still don't trigger workflow run.

No reaction on comments

Hey,

I'm using it with following:

        uses: trstringer/manual-approval@v1
        with:
          secret: ...
          approvers: ...
          minimum-approvals: ...
          issue-title: ...
          exclude-workflow-initiator-as-approver: false

The 1.8.0 version is in use.
Once the issue is raised, and a comment like "approve" is placed, nothing is happening.
There is no another action from bot, that would close the issue and move forward the pipeline, it will stay in waiting for 6hrs.

What is wrong? Is it a bug or am I missing something?

How to continue even if the issue is canceled

hello trstringer
If the approval is yes, I would like to continue the distribution and if the approval is no, I would like to create a pipeline that rolls back to the previous image.
However, it is difficult because the pipeline is interrupted when you enter the no.
Is it possible?
Thank you so much and I hope you're always happy

In a self-host-Runner environment, error retrieving approvers: error parsing exclude-workflow-initiator-as-approver flag: strconv.ParseBool: parsing "": invalid syntax An error will occur

The following error occurs.

error retrieving approvers: error parsing exclude-workflow-initiator-as-approver flag: strconv.ParseBool: parsing "": invalid syntax

my workflow step:

          - uses: trstringer/manual-approval@v1
             with:
                 secret: ${{ github.TOKEN }}
                 approvers: jieey1140
                 minimum-approvals: 1
                 issue-title: 'Deploying Production'

self-host-runner ENV:

OS: Ubuntu 22.04
Docker: Installed.

I need your help!

Issue body maximum is 65536 characters

This Action should note that maximum size of an issue body is 65536 characters. Attempting to create an issue larger than this results in:

422 Validation Failed [{Resource:Issue Field:body Code:custom Message:body is too long (maximum is 65536 characters)}]

It probably makes sense to emit a warning and truncate issue bodies which exceed this limit.

Custom title for approval Issue.

I suggest the ability to pass a full custom title. Right now it looks like this:

Manual approval required for workflow run 4348714510: {issue-title}

I would also like complete control over the title if possible and feel this would be a useful feature.

Manual approval doesn't work between steps for workflow

Hi Trstringer,

I am trying to use trstringer/manual-approval@v1 between workflow,however, it complains:
Attempting to expand user say-way/Torsten Sprenger as a group (may not succeed)
GET https://api.github.com/orgs/say-way/teams/Torsten%20Sprenger/members: 404 Not Found []
Attempting to expand user say-way/saywaydeploy as a group (may not succeed)
GET https://api.github.com/orgs/say-way/teams/saywaydeploy/members: 404 Not Found []
Creating issue in repo say-way/analytics-api with the following content:
Title: Manual approval required for workflow run 3338938915
Approvers: [Torsten Sprenger saywaydeploy]
Body:
Workflow is pending manual review.
URL: https://github.com/say-way/analytics-api/actions/runs/3338938915

Required approvers: [Torsten Sprenger saywaydeploy]

Respond "approved", "approve", "lgtm", "yes" to continue workflow or "denied", "deny", "no" to cancel.
error creating issue: POST https://api.github.com/repos/say-way/analytics-api/issues: 410 Issues are disabled for this repo []

Here is the workflow:

deploy-demo:
needs: build-and-push
name: deployment in demo cluster
environment: demo
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write

env:
  aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
  aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
  aws-region: ${{ secrets.AWS_REGION }}
  username: ${{ secrets.USERNAME }}
  secret: ${{ secrets.DEPLOY_PAT }}
  ssh-key: ${{ secrets.SSHKEY }}
  
steps:
  - name: Approval Demo
    uses: trstringer/[email protected]
    with:
      secret: ${{ secrets.PACKAGE_PAT }}
      approvers: DevOps
      minimum_approvals: 1

  - name: Get Login to AWS ECR
    uses: aws-actions/configure-aws-credentials@v1
    with:
      aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
      aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
      role-to-assume: ${{ secrets.ROLE_ASSUME }}
      aws-region: eu-central-1
      role-session-name: OIDCSession
      audience: sts.amazonaws.com
      
  - name: Login to Amazon ECR
    id: login-ecr
    uses: aws-actions/amazon-ecr-login@v1

422 Validation Failed

Latest runs fails with following error msg

error creating issue: POST https://api.github.com/repos/*/*/issues: 422 Validation Failed [{Resource:Issue Field:assignees Code:invalid Message:}]

Full error message:

Creating issue in repo smartlook/smartlook-devops with the following content:
Title: Manual approval required for workflow run 11111111: Terraform deployment to prod environment
Approvers: [user1 user2 user3]
Body:
Workflow is pending manual review.
URL: https://github.com/smartlook/smartlook-devops/actions/runs/11111111

Required approvers: [user1 user2 user3]

Respond "approved", "approve", "lgtm", "yes" to continue workflow or "denied", "deny", "no" to cancel.
error creating issue: POST https://api.github.com/repos/*/*/issues: 422 Validation Failed [{Resource:Issue Field:assignees Code:invalid Message:}]

Use it in following configuration:

- name: Manual approval
  id: approve
  uses: trstringer/manual-approval@v1
  timeout-minutes: 1
  with:
    secret: ${{ github.TOKEN }}
    approvers: user1,user2,user3
    minimum-approvals: 1
    issue-title: "Terraform deployment to ${{ matrix.env }} environment"
    exclude-workflow-initiator-as-approver: false

Discovered it today. Worked flawless previously.

Any ideas regarding the reason?

Thanks

Argument list too long

Hi,
I'm trying to use this to open an issue with pulumi changes from pulumi preview before a pulumi up command.

Not sure how to go about fixing this error.

Error:

Run trstringer/manual-approval@v1
/usr/bin/docker run --name ghcriotrstringermanualapproval190_df3334 --label 49859c --workdir /github/workspace --rm -e "CLOUDSDK_AUTH_CREDENTIAL_FILE_OVERRIDE" -e "GOOGLE_APPLICATION_CREDENTIALS" -e "GOOGLE_GHA_CREDS_PATH" -e "CLOUDSDK_CORE_PROJECT" -e "CLOUDSDK_PROJECT" -e "GCLOUD_PROJECT" -e "GCP_PROJECT" -e "GOOGLE_CLOUD_PROJECT" -e "PULUMI_DIFF" -e "PULUMI_PLAN" -e "INPUT_SECRET" -e "INPUT_APPROVERS" -e "INPUT_MINIMUM-APPROVALS" -e "INPUT_ISSUE-TITLE" -e "INPUT_ISSUE-BODY" -e "INPUT_EXCLUDE-WORKFLOW-INITIATOR-AS-APPROVER" -e "INPUT_ADDITIONAL-APPROVED-WORDS" -e "INPUT_ADDITIONAL-DENIED-WORDS" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/GCP/GCP":"/github/workspace" ghcr.io/trstringer/manual-approval:1.9.0
Error: An error occurred trying to start process '/usr/bin/docker' with working directory '/home/runner/work/GCP/GCP'. Argument list too long

Action:

name: Pulumi
on:
  workflow_dispatch:
jobs:
  up:
    name: Update
    runs-on: ubuntu-latest
    steps:
      - name: Checkout ๐Ÿ›Ž๏ธ
        uses: actions/checkout@v3

      - name: Authenticate with Google ๐Ÿ”‘
        uses: 'google-github-actions/auth@v1'
        with:
          credentials_json: '${{ secrets.KEY}}'      
      
      - name: Setup Go โœจ
        uses: actions/setup-go@v3
        with:
          go-version: '1.20'
          
      - name: Downloading dependencies ๐Ÿ“ฆ
        run: |
          cd ./pulumi
          go mod download
    
      - name: Install pulumi
        uses: pulumi/setup-pulumi@v2
        with:
          pulumi-version: latest
          
      - name: Check pulumi is working
        run: |
          pulumi version
          pulumi login gs://state-of-deployment
        
      - name: Pulumi preview
        run: |
          cd pulumi
          echo ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} > ./passfile
          export PULUMI_CONFIG_PASSPHRASE_FILE=./passfile
          
          OUTPUT_DIFF=$(pulumi preview --refresh --stack STACK --diff --save-plan plan.json)
          
          echo "PULUMI_DIFF<<EOF" >> $GITHUB_ENV
          echo "${OUTPUT_DIFF}" >> $GITHUB_ENV
          echo "EOF" >> $GITHUB_ENV
          
          echo "PULUMI_PLAN<<EOF" >> $GITHUB_ENV
          cat plan.json >> $GITHUB_ENV
          echo "EOF" >> $GITHUB_ENV

      - name: "Wait for approval"
        uses: trstringer/manual-approval@v1
        with:
          secret: ${{ github.TOKEN }}
          approvers: devsecops
          minimum-approvals: 1
          issue-title: "Deploying pulumi, check action"
          issue-body: "Approval of the pulumi-deploy action\n ${env.PULUMI_DIFF}"
          exclude-workflow-initiator-as-approver: false
          additional-approved-words: ''
          additional-denied-words: ''      
          
      - name: Pulumi up
        run: |
          cd pulumi
          echo ${{ secrets.PULUMI_CONFIG_PASSPHRASE }} > ./passfile
          export PULUMI_CONFIG_PASSPHRASE_FILE=./passfile
          
          ls
          echo "${env.PULUMI_PLAN}" > plan.json
          cat plan.json
          echo "SUCCESS"
      #    pulumi up --refresh -y --skip-preview --stack STACK --plan plan.json

Timeout setting does not work

I've set

         timeout-minutes: 3

and it does not seem to work out. Cancelled it manually after 7 minutes:

Tue, 04 Oct 2022 14:03:25 GMT
Respond "approved", "approve", "lgtm", "yes" to continue workflow or "denied", "deny", "no" to cancel.
Tue, 04 Oct 2022 14:03:26 GMT
Workflow status: Pending
...
Tue, 04 Oct 2022 14:10:28 GMT
Workflow status: Pending
Tue, 04 Oct 2022 14:10:35 GMT
Workflow cancelled, closing issue.
Tue, 04 Oct 2022 14:10:37 GMT
Error: The operation was canceled.

GitHub Issues can only have up to 10 people assigned to a issue

Example Config

steps:
  - uses: trstringer/manual-approval@v1
    with:
      secret: ${{ github.TOKEN }}
      approvers: org-team1

If your org-team1 has more than 10 users, only 10 users will be added to the issue. The workflow does not generate a error. This limitation should be documented.


Screenshot 2023-04-19 at 3 37 25 PM

Is there a way to have this spit out a link to the issue it creates?

I noticed that when waiting for approval, this presents a link to the current job being run by the github action in the job output console. It would be neat if there was a way to display the link to the issue created for approval in said console output as opposed to waiting for it to appear in the "Issues" tab.

Pausing is very cost expensive

Please add a more prominent warning, that using this action is pausing a github runner. So if you use private repos, you get heavily billed.

Unexpected input(s): 'timeout-minutes'? #48

Hi,
I am using trstringer/manual-approval@v1 in my github actions and observed that I am receiving annotation warnings for issue-body.

     uses: trstringer/manual-approval@v1
     with:
        secret: ${{ github.TOKEN }}
        approvers: user1,user2
        minimum-approvals: 1
        issue-title: 'Deploying to prod'
        issue-body: 'Please approve or deny the prod deployment'
        exclude-workflow-initiator-as-approver: false
Unexpected input(s) 'issue-body', valid inputs are ['entryPoint', 'args', 'approvers', 'secret', 'minimum-approvals', 'issue-title', 'exclude-workflow-initiator-as-approver']

Any suggestions would be helpful.

Manual approval doesn't work between steps of terraform plan and apply

Hi,

I am trying to use trstringer/manual-approval@v1 between terraform plan and apply, however it complains:
Attempting to expand user xiaoanne/xiaoanne as a group (may not succeed)
GET https://api.github.com/orgs/xiaoanne/teams/xiaoanne/members: 404 Not Found []
Creating issue in repo xiaoanne/aws-h1 with the following content:
Title: Manual approval required for workflow run 3286175439
Approvers: [xiaoanne]
Body:
Workflow is pending manual review.
URL: https://github.com/xiaoanne/aws-h1/actions/runs/3286[17](https://github.com/xiaoanne/aws-h1/actions/runs/3286175439/jobs/5414000367#step:7:18)5439

Required approvers: [xiaoanne]

Respond "approved", "approve", "lgtm", "yes" to continue workflow or "denied", "deny", "no" to cancel.
error creating issue: POST https://api.github.com/repos/xiaoanne/aws-h1/issues: 403 Resource not accessible by integration []

Here is the workflow:

name: 'Terraform'
on:
push:
branches: #[ "main" ]
- 'main'
- 'test'
pull_request:

permissions:
contents: read

jobs:
setup:
name: 'Terraform'
runs-on: ubuntu-latest
environment: dev

# Use the Bash shell, set working directory
defaults:
  run:
    shell: bash
    working-directory: ./website_s3

steps:
# Checkout the repository to the GitHub Actions runner
- name: Checkout
  uses: actions/checkout@v3

# Set the AWS access key and secret access key
- name: Configure AWS Credentials
  uses: aws-actions/configure-aws-credentials@v1
  with:
    aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
    aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
    aws-region: ap-southeast-2

# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
  uses: hashicorp/setup-terraform@v1
  with:
    cli_config_credentials_token: ${{ secrets.TF_API_TOKEN }}

# Initialize a new or existing Terraform working directory, run the plan to generate tfplan.out for terraform apply to use
- name: Terraform Init/Plan
  run: |
    terraform fmt -check
    terraform init
    terraform plan -input=false -out=tfplan.out

# The assigned approvers need to manually approve to proceed with terraform apply
**- name: Manual approve**     # Failed in here
  uses: trstringer/manual-approval@v1
  with:
    secret: ${{ github.TOKEN }}
    approvers: xiaoanne
    minimum-approvals: 1

# Apply and/or destroy the infrastructure
- name: Terraform Apply/Destroy
  run: |
    terraform apply tfplan.out
    sleep 10
    terraform destroy -auto-approve

Trim whitespace from usernames.

Github's username policies don't allow spaces. Can we update our code to trim them from usernames?

image

Since we know usernames won't have spaces and we also know that people tend to enter spaces after commas, let's update our code to trim spaces from usernames?

This way if a user enters
approvers: User1, User2, User3
It will still work. Currently it fails because we are searching for usernames that literally start with a space.

Unable to Expand Org Team

Hi There

Currently utilising this action within a new pipeline and have ran into the following issue.
This works when using individual org users but not team names.

      - name: Generate Approval token
        id: generate_token
        uses: tibdex/github-app-token@v1
        with:
          app_id: ${{ secrets.GLOBAL_WORKFLOW_APPROVAL_APP_ID }}
          private_key: ${{ secrets.GLOBAL_WORKFLOW_APPROVAL_APP_PRIVATE_KEY }}

      - name: Wait for execution approval
        id: procceed-with-execution-of-aws-sandbox-nuke
        uses: trstringer/manual-approval@v1
        with:
          secret: ${{ steps.generate_token.outputs.token }}
          approvers: ${{ env.GITHUB_TEAM_NAME }}
          minimum-approvals: 1
          issue-title: "${{ github.action }}" # optional - default is "Manual Approval"
Attempting to expand user snowplow-devops/com.snowplowanalytics.engineeringproductivity as a group (may not succeed)
GET https://api.github.com/orgs/snowplow-devops/teams/com.snowplowanalytics.engineeringproductivity/members: 404 Not Found []
Creating issue in repo snowplow-devops/engineering-productivity with the following content:
Title: Manual approval required for workflow run 3368332814: procceed-with-execution-of-aws-sandbox-nuke

Any help appreciated!

State the limitations and considerations

The readme should reflect the following limitations and considerations:

  • While the workflow is paused, it will take a concurrent job spot
  • A job is only allowed to run for a maximum of 6 hours and then it'll be failed
  • The paused workflow is still compute that is running that could incur costs like any other idling VM

More information here on GitHub docs.

Readme is not up to date with `v1.8.0` tag

Hi there, just a notice, that you have changes and documentation in the readme, that is not reflective of the latest release which I found a bit confusing.

I was trying to use issue-body but in fact v1.8.0 does not have this functionality.

Are you planning on releasing it?

keywords with new line doesnt work

In the issue, if any approvers type a valid keyword ("yes", "approve", etc) and new line at the end. the action doesnt recognize as valid keyword and still waiting for approve/deny

403 API rate limit causes to approval job to fail

Thanks for providing this action, it's a much needed pattern for those of us without GHE.

We are hitting an issue fairly regularly that is making it difficult to integrate however. Once the approval issue is opened, it seems the action makes repeated calls to the GH API to check for the existence of an approve/deny comment.

After a while (less than an hour) that call gets rejected with a 403:

error getting comments: GET https://api.github.com/repos/<redacted>/<redacted>/issues/905/comments: 403 API rate limit exceeded for installation ID 15708728. [rate reset in 9m20s

This error then fails the workflow and the approval issue becomes orphaned. We have to manually close the issue, and manually re-run the failed job, creating another issue.

Is there a way around this? Can we configure interval between those repeated API calls to be longer?

It seems like this is currently set to 10 seconds. This obviously makes the action more responsive once an approve/deny comment has been made, but it could likely be increased a fair amount and still be well within acceptable limits while still giving the desired functionality.

For context, we often have 2 of these approval jobs running (eg, a PR containing changes to 2 services, each with their own approval process).

Org team approver

Hi team,
i am trying to implement this on org level, have followed the instructions as given on readme but getting docker unauthorised error when am using this action, the action is private. When we are commenting this action we able to pull the docker image.
image
Have tried passing ghcr credentials also tried with giving admin access to the github app for generating token.

Not supporting linux/arm64 based runners

Hi @trstringer,
I am facing this(screenshot) issue on my self-hosted arm64 based linux ec2 instance.
image

I would appreciate if you could deploy docker image with both amd64 and arm64 manifests, currently image with Dockerfile configuration on have single arch i.e, amd64.

Hope you will update this soon โœŒ๏ธ. Thanks In advance ๐Ÿ™‚

increase log level

The action worked well till yesterday, however, now it's in some way blocked in "Workflow status: Pending" despite having answered "yes" to the issue created. I can't understand what it's causing the stall.

If I cancel the workflow, then the issue is closed in automagic.

It's possible to improve the log details of "why" the workflow it's pending? Maybe it's a GitHub issue.

Screenshot 2023-02-10 at 09 54 15

422: Validation Failed while using manual approval task in GitHub actions

I am getting 422 validation failed error while manual-approval task is getting executed as part of my workflow. This is not happening on my personal organizational repository.

Here's the error from workflow execution:

/usr/bin/docker run --name ghcriotrstringermanualapproval120_1e2292 --label 08450d --workdir /github/workspace --rm -e pat_token -e INPUT_SECRET -e INPUT_APPROVERS -e INPUT_MINIMUM-APPROVALS -e HOME -e GITHUB_JOB -e GITHUB_REF -e GITHUB_SHA -e GITHUB_REPOSITORY -e GITHUB_REPOSITORY_OWNER -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_RETENTION_DAYS -e GITHUB_RUN_ATTEMPT -e GITHUB_ACTOR -e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF -e GITHUB_EVENT_NAME -e GITHUB_SERVER_URL -e GITHUB_API_URL -e GITHUB_GRAPHQL_URL -e GITHUB_REF_NAME -e GITHUB_REF_PROTECTED -e GITHUB_REF_TYPE -e GITHUB_WORKSPACE -e GITHUB_ACTION -e GITHUB_EVENT_PATH -e GITHUB_ACTION_REPOSITORY -e GITHUB_ACTION_REF -e GITHUB_PATH -e GITHUB_ENV -e GITHUB_STEP_SUMMARY -e RUNNER_OS -e RUNNER_ARCH -e RUNNER_NAME -e RUNNER_TOOL_CACHE -e RUNNER_TEMP -e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN -e ACTIONS_CACHE_URL -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/xxxxxxxxxxx":"/github/workspace" ghcr.io/trstringer/manual-approval:1.2.0
Required approvers: saikrishna-snp, apeechara-nacha
error creating issue: POST https://api.github.com/repos/xxxxxxx/xxxxxxxx/issues: 422 Validation Failed [{Resource:Issue Field:assignees Code:invalid Message:}]

Add individual members in a github team/org

Hi @trstringer

I'm not sure whether this is possible or not without a PAT but I want to add individual members under a particular org.

  • not complete org
  • not a team
  • but only a single member -> I'm not sure whether the action also works on members without considering them as a part of org/team
      - name: Manual Approval
        uses: trstringer/manual-approval@v1
        with:
          secret: ${{ secrets.GITHUB_TOKEN }}
          approvers: user1,user2,user3
          minimum-approvals: 1

I'm getting the following error:

Attempting to expand user <org-name>/<user1> as a group (may not succeed)
GET https://api.github.com/orgs/<org-name>/teams/<user1>/members: 404 Not Found []

Let me know if I'm missing something.

Any help is appreciated.

Include a web UI link of the created issue in output so that readers can easily go to the issue in their browsers

Everything works fine and it's brilliant - I can have approval steps without having to pay $231/year for my side project.

Currently, when the action is triggered and creates the approval issue, it outputs text resembling this:

Creating issue in repo org/repo_name with the following content:
Title: Manual approval required for workflow run 33333333333333
Approvers: [xxxx]
Body:
Workflow is pending manual review.
URL: https://github.com/org/repo_name/actions/runs/444444444444

Required approvers: [xxxx]

Respond "approved", "approve", "lgtm", "yes" to continue workflow or "denied", "deny", "no" to cancel.
Issue created: https://api.github.com/org/repo_name/infra_management/issues/4
Workflow status: Pending
Workflow status: Pending
Workflow status: Pending

I click the URL, then edit it to point to the web page for that issue (e.g. https://github.com/org/repo_name/infra_management/issues/4)

It would be amazing if this web URL could be outputted as well to remove this little niggling manual step.

Specify issue Template

This allows the issue created to have a pre-deployment checklist and other notes which can be made before approval is made, which helps establish a proper process

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.