Github Actions for "wait_for_approval" Stage
As we know that there are no native way in github to wait for approval like jenkins. This is an approach to wait for approval within the actions via a dummy PR and waiting for its approval and to proceed further post approval.
if you need an additional layer of approval on top of your existing PR.
Like: Waiting for approval during terraform apply or during some test cases or deployment or any other use cases where you need to hold before proceeding to the next step
- Ensure that you have GITHUB_TOKEN which has permissions to create a feature branch,PR and to merge a PR and have it in the github secrets.
- Ensure you provide all the necessary inputs as requested when you call the actions
An action has been created to add an approval stage within the workflow
Once this action is added with the requested inputs like repo name, default branch name, org, pr_reviewer , github_token, time-limit etc . The action is then triggered and does the following.
-
Creates a new feature branch in the repository that is mentioned in the inputs.
-
Creates a dummy commit with some default details like who triggered it along with the date and workflow number.
-
Creates a PR and waits for the approval from the reviewer. It can be an individual person or a team as mentioned in the inputs.
-
The approval wait time depends on the time-limit inputs in seconds. The workflow run will wait until the approved has approved within that time frame and then proceeds with the further action.
Use this action within your GitHub workflow step where you need to wait for some additional approval before proceeding to the next step.
- name: Wait_for_approval Action
uses: arun291091/wait_for_approval_gha@v1
with:
base_repository_branch: <Base branch name>
github_org: <org name>
repository_name: <repo name>
pr_reviewer: <reviewer1>,<reviewer2>,<reviewer3>
time_limit: <time wait for approval in Seconds>
github_token: <Github auth token>
Where
- base_repository_branch : Should be the default branch name of the specific repository either main or master
- github_org : The Github organization name
- repository_name: The name of the repository where you need the dummy PR approval to be.
- pr_reviewer : PR reviewer can be a team or an individual member whom you would need to Wait for approval. you can add multiple reviewers separated by comma.
- time_limit: Waiting time in Seconds for the approval
- github_token: Github Auth token with necessary permissions to create/merge PR, branch .
Raise an issue via github for any issues.
- Authentication using Github App
- Adding a custom content for the dummy PR.