Merge 6a161423fd into 3441ed44b6
This commit is contained in:
commit
f78b50c161
5 changed files with 13 additions and 2 deletions
|
|
@ -43,6 +43,7 @@ steps:
|
|||
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."
|
||||
issue-labels: "deployment"
|
||||
exclude-workflow-initiator-as-approver: false
|
||||
fail-on-denial: true
|
||||
additional-approved-words: ''
|
||||
|
|
@ -53,6 +54,7 @@ steps:
|
|||
* `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.
|
||||
* `issue-labels` is a comma separated list of strings that will be added as labels to 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.
|
||||
* `fail-on-denial` is a boolean that indicates if the workflow should fail if any approver denies the approval. This is optional and defaults to `true`. Set this to `false` to allow the workflow to continue if any approver denies the approval.
|
||||
* `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.
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ inputs:
|
|||
issue-body:
|
||||
description: The custom body for the issue
|
||||
required: false
|
||||
issue-labels:
|
||||
description: Labels to add to the issue
|
||||
required: false
|
||||
exclude-workflow-initiator-as-approver:
|
||||
description: Whether or not to filter out the user who initiated the workflow as an approver if they are in the approvers list
|
||||
required: false
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ type approvalEnvironment struct {
|
|||
approvalIssueNumber int
|
||||
issueTitle string
|
||||
issueBody string
|
||||
issueLabels []string
|
||||
issueApprovers []string
|
||||
minimumApprovals int
|
||||
targetRepoOwner string
|
||||
|
|
@ -27,7 +28,7 @@ type approvalEnvironment struct {
|
|||
failOnDenial bool
|
||||
}
|
||||
|
||||
func newApprovalEnvironment(client *github.Client, repoFullName, repoOwner string, runID int, approvers []string, minimumApprovals int, issueTitle, issueBody string, targetRepoOwner string, targetRepoName string, failOnDenial bool) (*approvalEnvironment, error) {
|
||||
func newApprovalEnvironment(client *github.Client, repoFullName, repoOwner string, runID int, approvers []string, minimumApprovals int, issueTitle, issueBody string, targetRepoOwner string, targetRepoName string, failOnDenial bool, issueLabels []string) (*approvalEnvironment, error) {
|
||||
repoOwnerAndName := strings.Split(repoFullName, "/")
|
||||
if len(repoOwnerAndName) != 2 {
|
||||
return nil, fmt.Errorf("repo owner and name in unexpected format: %s", repoFullName)
|
||||
|
|
@ -47,6 +48,7 @@ func newApprovalEnvironment(client *github.Client, repoFullName, repoOwner strin
|
|||
targetRepoOwner: targetRepoOwner,
|
||||
targetRepoName: targetRepoName,
|
||||
failOnDenial: failOnDenial,
|
||||
issueLabels: issueLabels,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
@ -100,6 +102,7 @@ func (a *approvalEnvironment) createApprovalIssue(ctx context.Context) error {
|
|||
Title: &issueTitle,
|
||||
Body: &issueBody,
|
||||
Assignees: &a.issueApprovers,
|
||||
Labels: &a.issueLabels,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ const (
|
|||
envVarMinimumApprovals string = "INPUT_MINIMUM-APPROVALS"
|
||||
envVarIssueTitle string = "INPUT_ISSUE-TITLE"
|
||||
envVarIssueBody string = "INPUT_ISSUE-BODY"
|
||||
envVarIssueLabels string = "INPUT_ISSUE-LABELS"
|
||||
envVarExcludeWorkflowInitiatorAsApprover string = "INPUT_EXCLUDE-WORKFLOW-INITIATOR-AS-APPROVER"
|
||||
envVarAdditionalApprovedWords string = "INPUT_ADDITIONAL-APPROVED-WORDS"
|
||||
envVarAdditionalDeniedWords string = "INPUT_ADDITIONAL-DENIED-WORDS"
|
||||
|
|
|
|||
4
main.go
4
main.go
|
|
@ -200,6 +200,8 @@ func main() {
|
|||
|
||||
issueTitle := os.Getenv(envVarIssueTitle)
|
||||
issueBody := os.Getenv(envVarIssueBody)
|
||||
issueLabels := strings.Split(strings.ReplaceAll(os.Getenv(envVarIssueLabels), " ", ""), ",")
|
||||
|
||||
minimumApprovalsRaw := os.Getenv(envVarMinimumApprovals)
|
||||
minimumApprovals := 0
|
||||
if minimumApprovalsRaw != "" {
|
||||
|
|
@ -210,7 +212,7 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
apprv, err := newApprovalEnvironment(client, repoFullName, repoOwner, runID, approvers, minimumApprovals, issueTitle, issueBody, targetRepoOwner, targetRepoName, failOnDenial)
|
||||
apprv, err := newApprovalEnvironment(client, repoFullName, repoOwner, runID, approvers, minimumApprovals, issueTitle, issueBody, targetRepoOwner, targetRepoName, failOnDenial, issueLabels)
|
||||
if err != nil {
|
||||
fmt.Printf("error creating approval environment: %v\n", err)
|
||||
os.Exit(1)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue