File tree Expand file tree Collapse file tree 3 files changed +11
-6
lines changed
Expand file tree Collapse file tree 3 files changed +11
-6
lines changed Original file line number Diff line number Diff line change 66 "os"
77)
88
9- // PullRequestEvent represents the structure of a GitHub Pull Request event payload.
9+ // Event represents the structure of a GitHub event payload.
1010// https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request
11- type PullRequestEvent struct {
11+ type EventPayload struct {
1212 PullRequest struct {
1313 State string `json:"state"`
1414 } `json:"pull_request"`
@@ -20,7 +20,7 @@ const (
2020 PRStateClosed = "closed"
2121)
2222
23- func GetPullRequestEvent () (* PullRequestEvent , error ) {
23+ func GetEventPayload () (* EventPayload , error ) {
2424 eventPath := os .Getenv (EnvGithubEventPath )
2525 if eventPath == "" {
2626 return nil , fmt .Errorf ("%s is not set" , EnvGithubEventPath )
@@ -31,7 +31,7 @@ func GetPullRequestEvent() (*PullRequestEvent, error) {
3131 return nil , fmt .Errorf ("failed to open GitHub event file: %w" , err )
3232 }
3333 defer eventFile .Close ()
34- var event PullRequestEvent
34+ var event EventPayload
3535 if err := json .NewDecoder (eventFile ).Decode (& event ); err != nil {
3636 return nil , fmt .Errorf ("failed to decode GitHub event JSON: %w" , err )
3737 }
Original file line number Diff line number Diff line change 88 description : ' Create preview branches using this actions instead of "auto-build" feature on AWS Amplify'
99 required : false
1010 default : " false"
11+ delete_branches :
12+ description : ' Delete preview branches using this actions when PR is closed'
13+ required : false
14+ default : " false"
1115 github_token :
1216 required : true
1317 description : " Github token with permissions to read/write comments in pull request"
5155 run : echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
5256 id : extract_branch
5357
54- - uses : actions/setup-go@v5
58+ - uses : actions/setup-go@v6
5559 with :
5660 go-version-file : ${{ github.action_path }}/go.mod
5761 cache-dependency-path : ${{ steps.cache_workaround.outputs.go_sum_path }}
6266 AMPLIFY_APP_IDS : ${{ inputs.app_ids }}
6367 GIT_BRANCH_NAME : ${{ steps.extract_branch.outputs.branch }}
6468 CREATE_BRANCHES : ${{ inputs.create_branches }}
69+ DELETE_BRANCHES : ${{ inputs.delete_branches }}
6570 GITHUB_TOKEN : ${{ inputs.github_token }}
6671 WAIT : ${{ inputs.wait }}
6772 WAIT_RETRIES : ${{ inputs.wait_retries }}
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ func setGithubOutputs(kv map[string]string) (err error) {
100100}
101101
102102func isPullRequestOpen () (bool , error ) {
103- event , err := github .GetPullRequestEvent ()
103+ event , err := github .GetEventPayload ()
104104 if err != nil {
105105 // Create preview just in case if error happened
106106 return false , fmt .Errorf ("failed to get pull request event: %w" , err )
You can’t perform that action at this time.
0 commit comments