diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index 0087f52..6e20834 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -49,6 +49,7 @@ describe('main.ts', () => { describe('run()', () => { it('Skips invalid events', async () => { github.context.eventName = 'push' + github.context.payload = {} as any await main.run() @@ -73,17 +74,6 @@ describe('main.ts', () => { ) }) - it('Fails if neither PR nor issue are provided', async () => { - github.context.payload.issue = undefined as any - github.context.payload.pull_request = undefined as any - - await main.run() - - expect(core.setFailed).toHaveBeenCalledWith( - 'Internal Error...No Issue or PR Provided by GitHub' - ) - }) - it('Fails if both PR and issue are provided', async () => { github.context.payload.issue = { number: 20 diff --git a/package-lock.json b/package-lock.json index 10662d7..c383e40 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,18 +1,17 @@ { "name": "first-interaction-action", - "version": "3.0.0", + "version": "3.1.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "first-interaction-action", - "version": "3.0.0", + "version": "3.1.0", "license": "MIT", "dependencies": { "@actions/core": "^1.11.1", "@actions/github": "^6.0.1", - "@octokit/rest": "^22.0.0", - "@rollup/rollup-linux-x64-gnu": "*" + "@octokit/rest": "^22.0.0" }, "devDependencies": { "@eslint/compat": "^1.3.2", @@ -13902,20 +13901,6 @@ "fsevents": "~2.3.2" } }, - "node_modules/rollup/node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.48.1", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.48.1.tgz", - "integrity": "sha512-90taWXCWxTbClWuMZD0DKYohY1EovA+W5iytpE89oUPmT5O1HFdf8cuuVIylE6vCbrGdIGv85lVRzTcpTRZ+kA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ] - }, "node_modules/run-parallel": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz", diff --git a/package.json b/package.json index 1309822..397e6b2 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "first-interaction-action", "description": "An action for greeting first time contributors.", - "version": "3.0.0", + "version": "3.1.0", "author": "GitHub", "type": "module", "private": true, diff --git a/src/main.ts b/src/main.ts index ae05613..9fa62e9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,11 +5,12 @@ import { Octokit } from '@octokit/rest' export async function run() { core.info('Running actions/first-interaction!') + // Check if this is an issue or PR event. + const isIssue = github.context.payload.issue !== undefined + const isPullRequest = github.context.payload.pull_request !== undefined + // Skip if this is not an issue or PR event. - if ( - github.context.eventName !== 'issues' && - github.context.eventName !== 'pull_request' - ) + if (!isIssue && !isPullRequest) return core.info('Skipping...Not an Issue/PR Event') // Skip if this is not an issue/PR open event. @@ -20,13 +21,7 @@ export async function run() { if (!github.context.payload.sender) return core.setFailed('Internal Error...No Sender Provided by GitHub') - // Check if this is an issue or PR event. - const isIssue = github.context.payload.issue !== undefined - const isPullRequest = github.context.payload.pull_request !== undefined - // Confirm that only one of the two is present. - if (!isIssue && !isPullRequest) - return core.setFailed('Internal Error...No Issue or PR Provided by GitHub') if (isIssue && isPullRequest) return core.setFailed( 'Internal Error...Both Issue and PR Provided by GitHub'