This repository demonstrate how to run a github action against multiple repository environments in which some of those environments need approval before deploying to the environment
Since this is a proof of concept project, the action does not deploy code to any servers but instead print the environment name at the end.
I defined 3 environments
Environment Name | Need approval |
---|---|
DEV | ❌ |
QA | ✅ |
PROD | ✅ |
This action package a Java based application and accepts environment name as input parameter. Action file is located in .github/workflows/environment-based.yml
- You need to have admin access to the repository. To create a new environment you can got to
Repository settings -> Environments -> click on new Environment
- The enter environment name and click on configure environment button
Click on environment name then enable Required reviewers
then in the search box type github handles and add desired reviewers
Click on environment name then enable Required reviewers
then in the search box type github handles and add desired reviewers
Go to Actions tab -> select the action from side menu -> click on Run workflow -> select environment -> click on run workflow green button
Since there is no reviewer required, it automatically starts and finishes the run and look into build and deploy summary
This step needs approval and when you trigger the action, it sends an approval request to reviewer (usually via email, it depends on your github notification settings)
In action run details page click on review deployment (if you are a reviewer) -> select the environment name in poped up window -> leave a comment if you want -> approve or reject the request
If you approve the request then action will be triggered and if you reject it then action's run will be cancelled.
You will see a Deployment reviews
box below action run