How to review GitHub Actions Dispatch Workflow’s inputs with environment protection
Overview
This post will go over two GitHub Actions’ features; environment and job summary.
1. Release with environment feature
With GitHub Actions’ environment feature, you can protect your GitHub Actions workflow such that all the protection rules pass before running the workflow. This feature can be used to ensure every release must be reviewed by somebody.
Example is as follows:
Now let’s configure environment in the settings of the repository. Note that the configuration requires the repo admin permission. In the following example, the production
environment always requires to get reviewed by the reviewers.
Other than that, you can also configure the deployment branches and environment secrets.
When you release it, the workflow is triggered. But the workflow requires a review. Before a review, the workflow is pending.
You can approve or reject the workflow.
This is very awesome feature, isn’t it?
However, what if we want to use it for workflow_dispatch?
2. Workflow Dispatch with environment
Similarly, we can set an environment for workflow_dispatch
. Let’s see the following example. The workflow has an input to specify logLevel
.
Let’s run the workflow dispatch! The workflow is waiting a review!
However, we can’t see the input value. Sometimes the input value of a workflow needs to be reviewed!
How can we review it?
The best future solution is, of course, GitHub Actions show all the conditions on the review pop-up.
But the current workaround would be just writing the inputs to Job summary so the reviewer can see it when reviewing.
Now you can see the inputs value in the Job Summary:
This is the current workaround for reviewing the inputs value of dispatch_workflow with environment protection.
Hopefully, GitHub Actions will support this feature natively for better review experience.