diff --git a/README.md b/README.md index a37c9bd..9158a4c 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ A simple Github Action that allows us to update the status of a commit. GitHub does not update the status of a commit when running workflow and therefore tools that rely on the context/status of a given commit are not compatible with it. -Currently the action supports `pull_request` and `push` events: -* When the event is `pull_request`, the action will set the status to the last commit in the pull request at the moment the workflow was triggered. +Currently the action supports `pull_request`, `pull_request_target` and `push` events: +* When the event is `pull_request` or `pull_request_target`, the action will set the status to the last commit in the pull request at the moment the workflow was triggered. * When the event is `push`, the action will set the status to the last commit pushed at the moment the workflow was triggered. ## Input Parameters @@ -279,4 +279,4 @@ tide: ## Development -__Important: Before pushing your changes run `make release` to generate all the correct files and clean stuff, etc...__ \ No newline at end of file +__Important: Before pushing your changes run `make release` to generate all the correct files and clean stuff, etc...__ diff --git a/dist/index.js b/dist/index.js index fe5bf69..e07f4c8 100644 --- a/dist/index.js +++ b/dist/index.js @@ -60,7 +60,7 @@ class GithubHelper { initialize() { var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11; return __awaiter(this, void 0, void 0, function* () { - if (github_1.context.eventName === 'pull_request') { + if (['pull_request', 'pull_request_target'].includes(github_1.context.eventName)) { this.isPR = true; this.owner = (_e = (_d = (_c = (_b = (_a = github_1.context.payload) === null || _a === void 0 ? void 0 : _a.pull_request) === null || _b === void 0 ? void 0 : _b.head) === null || _c === void 0 ? void 0 : _c.repo) === null || _d === void 0 ? void 0 : _d.owner) === null || _e === void 0 ? void 0 : _e.login; this.repo = (_j = (_h = (_g = (_f = github_1.context.payload) === null || _f === void 0 ? void 0 : _f.pull_request) === null || _g === void 0 ? void 0 : _g.head) === null || _h === void 0 ? void 0 : _h.repo) === null || _j === void 0 ? void 0 : _j.name; @@ -455,8 +455,9 @@ const github = __importStar(__nccwpck_require__(5438)); function validateEventType() { return __awaiter(this, void 0, void 0, function* () { if (github.context.eventName !== 'pull_request' && + github.context.eventName !== 'pull_request_target' && github.context.eventName !== 'push') { - throw new Error('Error, action only works for pull_request or push events!'); + throw new Error('Error, action only works for pull_request, pull_request_target or push events!'); } }); } diff --git a/src/githubHelper.ts b/src/githubHelper.ts index a3c16c1..039a8e9 100644 --- a/src/githubHelper.ts +++ b/src/githubHelper.ts @@ -34,7 +34,7 @@ class GithubHelper { } private async initialize(): Promise { - if (context.eventName === 'pull_request') { + if (['pull_request', 'pull_request_target'].includes(context.eventName)) { this.isPR = true this.owner = context.payload?.pull_request?.head?.repo?.owner?.login this.repo = context.payload?.pull_request?.head?.repo?.name diff --git a/src/utils.ts b/src/utils.ts index adcaa2e..3d3d9a5 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -3,8 +3,11 @@ import * as github from '@actions/github' export async function validateEventType(): Promise { if ( github.context.eventName !== 'pull_request' && + github.context.eventName !== 'pull_request_target' && github.context.eventName !== 'push' ) { - throw new Error('Error, action only works for pull_request or push events!') + throw new Error( + 'Error, action only works for pull_request, pull_request_target or push events!' + ) } }