From 1beff3279ca32d1a505f9e7e5124caefd3227355 Mon Sep 17 00:00:00 2001 From: Ana Maria Martinez Gomez Date: Wed, 19 May 2021 22:42:03 +0200 Subject: [PATCH] Support pull_request_target `pull_request_target` is granted a read/write repository token and runs in the context of the base of the pull request. It allows to create workflows that label and comment on pull requests based on the contents of the event payload. The `get-changed-files` action is useful for some of those actions and the code works for this case with almost no modification. --- README.md | 2 +- dist/index.js | 1 + src/main.ts | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3f4401bf..51860f8a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ # Get All Changed Files -Get all of the files changed/modified in a pull request or push's commits. +Get all of the files changed/modified in a pull request (`pull_request` or `pull_request_target`) or push's commits. You can choose to get all changed files, only added files, only modified files, only removed files, only renamed files, or all added and modified files. These outputs are available via the `steps` output context. The `steps` output context exposes the output names `all`, `added`, `modified`, `removed`, `renamed`, and `added_modified`. diff --git a/dist/index.js b/dist/index.js index 72c16629..cf953550 100644 --- a/dist/index.js +++ b/dist/index.js @@ -3529,6 +3529,7 @@ function run() { let base; let head; switch (eventName) { + case 'pull_request_target': case 'pull_request': base = (_b = (_a = github_1.context.payload.pull_request) === null || _a === void 0 ? void 0 : _a.base) === null || _b === void 0 ? void 0 : _b.sha; head = (_d = (_c = github_1.context.payload.pull_request) === null || _c === void 0 ? void 0 : _c.head) === null || _d === void 0 ? void 0 : _d.sha; diff --git a/src/main.ts b/src/main.ts index 0f0fdd61..307b9888 100644 --- a/src/main.ts +++ b/src/main.ts @@ -26,6 +26,7 @@ async function run(): Promise { let head: string | undefined switch (eventName) { + case 'pull_request_target': case 'pull_request': base = context.payload.pull_request?.base?.sha head = context.payload.pull_request?.head?.sha