From f11e00bf313d88c02793b0dab51182fc1db9d4b7 Mon Sep 17 00:00:00 2001 From: Marco Stuurman Date: Fri, 4 Oct 2024 19:12:24 +0200 Subject: [PATCH 1/2] Add option for using a file as input for the issue body --- Dockerfile | 6 +++--- action.yaml | 3 +++ constants.go | 1 + main.go | 12 +++++++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6ec73aa..01419ae 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -FROM golang:1.17 AS builder +FROM golang:1.23 AS builder COPY . /var/app WORKDIR /var/app RUN CGO_ENABLED=0 go build -o app . -FROM alpine:3.14 -LABEL org.opencontainers.image.source https://github.com/trstringer/manual-approval +FROM alpine:3.20 +LABEL org.opencontainers.image.source=https://github.com/trstringer/manual-approval RUN apk update && apk add ca-certificates COPY --from=builder /var/app/app /var/app/app CMD ["/var/app/app"] diff --git a/action.yaml b/action.yaml index 7866c0b..d14ab43 100644 --- a/action.yaml +++ b/action.yaml @@ -22,6 +22,9 @@ inputs: issue-body: description: The custom body for the issue required: false + issue-body-file-path: + description: The file path to a custom body for 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 default: false diff --git a/constants.go b/constants.go index 03e4b4e..e0c8de2 100644 --- a/constants.go +++ b/constants.go @@ -18,6 +18,7 @@ const ( envVarMinimumApprovals string = "INPUT_MINIMUM-APPROVALS" envVarIssueTitle string = "INPUT_ISSUE-TITLE" envVarIssueBody string = "INPUT_ISSUE-BODY" + envVarIssueBodyFilePath string = "INPUT_ISSUE-BODY-FILE-PATH" envVarExcludeWorkflowInitiatorAsApprover string = "INPUT_EXCLUDE-WORKFLOW-INITIATOR-AS-APPROVER" envVarAdditionalApprovedWords string = "INPUT_ADDITIONAL-APPROVED-WORDS" envVarAdditionalDeniedWords string = "INPUT_ADDITIONAL-DENIED-WORDS" diff --git a/main.go b/main.go index 5aad15e..0c66b74 100644 --- a/main.go +++ b/main.go @@ -171,7 +171,17 @@ func main() { } issueTitle := os.Getenv(envVarIssueTitle) - issueBody := os.Getenv(envVarIssueBody) + var issueBody string + if os.Getenv(envVarIssueBodyFilePath) != "" { + fileContents, err := os.ReadFile(os.Getenv(envVarIssueBodyFilePath)) + if err != nil { + fmt.Printf("error reading issue body file: %v\n", err) + os.Exit(1) + } + issueBody = string(fileContents) + } else { + issueBody = os.Getenv(envVarIssueBody) + } minimumApprovalsRaw := os.Getenv(envVarMinimumApprovals) minimumApprovals := 0 if minimumApprovalsRaw != "" { From d045161a396acb3cdc694a60bc4bc6eafb83995e Mon Sep 17 00:00:00 2001 From: Marco Stuurman Date: Tue, 8 Oct 2024 13:10:39 +0200 Subject: [PATCH 2/2] Revert irrelevant version bumps --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 01419ae..6ec73aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,10 +1,10 @@ -FROM golang:1.23 AS builder +FROM golang:1.17 AS builder COPY . /var/app WORKDIR /var/app RUN CGO_ENABLED=0 go build -o app . -FROM alpine:3.20 -LABEL org.opencontainers.image.source=https://github.com/trstringer/manual-approval +FROM alpine:3.14 +LABEL org.opencontainers.image.source https://github.com/trstringer/manual-approval RUN apk update && apk add ca-certificates COPY --from=builder /var/app/app /var/app/app CMD ["/var/app/app"]