Merge pull request #349 from actions/ncalteen/events
This commit is contained in:
+1
-11
@@ -49,6 +49,7 @@ describe('main.ts', () => {
|
|||||||
describe('run()', () => {
|
describe('run()', () => {
|
||||||
it('Skips invalid events', async () => {
|
it('Skips invalid events', async () => {
|
||||||
github.context.eventName = 'push'
|
github.context.eventName = 'push'
|
||||||
|
github.context.payload = {} as any
|
||||||
|
|
||||||
await main.run()
|
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 () => {
|
it('Fails if both PR and issue are provided', async () => {
|
||||||
github.context.payload.issue = {
|
github.context.payload.issue = {
|
||||||
number: 20
|
number: 20
|
||||||
|
|||||||
+4
-7
@@ -34825,9 +34825,11 @@ const Octokit = Octokit$1.plugin(requestLog, legacyRestEndpointMethods, paginate
|
|||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
coreExports.info('Running actions/first-interaction!');
|
coreExports.info('Running actions/first-interaction!');
|
||||||
|
// Check if this is an issue or PR event.
|
||||||
|
const isIssue = githubExports.context.payload.issue !== undefined;
|
||||||
|
const isPullRequest = githubExports.context.payload.pull_request !== undefined;
|
||||||
// Skip if this is not an issue or PR event.
|
// Skip if this is not an issue or PR event.
|
||||||
if (githubExports.context.eventName !== 'issues' &&
|
if (!isIssue && !isPullRequest)
|
||||||
githubExports.context.eventName !== 'pull_request')
|
|
||||||
return coreExports.info('Skipping...Not an Issue/PR Event');
|
return coreExports.info('Skipping...Not an Issue/PR Event');
|
||||||
// Skip if this is not an issue/PR open event.
|
// Skip if this is not an issue/PR open event.
|
||||||
if (githubExports.context.action !== 'opened')
|
if (githubExports.context.action !== 'opened')
|
||||||
@@ -34835,12 +34837,7 @@ async function run() {
|
|||||||
// Confirm the sender data is present.
|
// Confirm the sender data is present.
|
||||||
if (!githubExports.context.payload.sender)
|
if (!githubExports.context.payload.sender)
|
||||||
return coreExports.setFailed('Internal Error...No Sender Provided by GitHub');
|
return coreExports.setFailed('Internal Error...No Sender Provided by GitHub');
|
||||||
// Check if this is an issue or PR event.
|
|
||||||
const isIssue = githubExports.context.payload.issue !== undefined;
|
|
||||||
const isPullRequest = githubExports.context.payload.pull_request !== undefined;
|
|
||||||
// Confirm that only one of the two is present.
|
// Confirm that only one of the two is present.
|
||||||
if (!isIssue && !isPullRequest)
|
|
||||||
return coreExports.setFailed('Internal Error...No Issue or PR Provided by GitHub');
|
|
||||||
if (isIssue && isPullRequest)
|
if (isIssue && isPullRequest)
|
||||||
return coreExports.setFailed('Internal Error...Both Issue and PR Provided by GitHub');
|
return coreExports.setFailed('Internal Error...Both Issue and PR Provided by GitHub');
|
||||||
// Get the action inputs.
|
// Get the action inputs.
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
Generated
+3
-18
@@ -1,18 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "first-interaction-action",
|
"name": "first-interaction-action",
|
||||||
"version": "3.0.0",
|
"version": "3.1.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "first-interaction-action",
|
"name": "first-interaction-action",
|
||||||
"version": "3.0.0",
|
"version": "3.1.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.11.1",
|
"@actions/core": "^1.11.1",
|
||||||
"@actions/github": "^6.0.1",
|
"@actions/github": "^6.0.1",
|
||||||
"@octokit/rest": "^22.0.0",
|
"@octokit/rest": "^22.0.0"
|
||||||
"@rollup/rollup-linux-x64-gnu": "*"
|
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@eslint/compat": "^1.3.2",
|
"@eslint/compat": "^1.3.2",
|
||||||
@@ -13902,20 +13901,6 @@
|
|||||||
"fsevents": "~2.3.2"
|
"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": {
|
"node_modules/run-parallel": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
||||||
|
|||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "first-interaction-action",
|
"name": "first-interaction-action",
|
||||||
"description": "An action for greeting first time contributors.",
|
"description": "An action for greeting first time contributors.",
|
||||||
"version": "3.0.0",
|
"version": "3.1.0",
|
||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
|
|||||||
+5
-10
@@ -5,11 +5,12 @@ import { Octokit } from '@octokit/rest'
|
|||||||
export async function run() {
|
export async function run() {
|
||||||
core.info('Running actions/first-interaction!')
|
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.
|
// Skip if this is not an issue or PR event.
|
||||||
if (
|
if (!isIssue && !isPullRequest)
|
||||||
github.context.eventName !== 'issues' &&
|
|
||||||
github.context.eventName !== 'pull_request'
|
|
||||||
)
|
|
||||||
return core.info('Skipping...Not an Issue/PR Event')
|
return core.info('Skipping...Not an Issue/PR Event')
|
||||||
|
|
||||||
// Skip if this is not an issue/PR open event.
|
// Skip if this is not an issue/PR open event.
|
||||||
@@ -20,13 +21,7 @@ export async function run() {
|
|||||||
if (!github.context.payload.sender)
|
if (!github.context.payload.sender)
|
||||||
return core.setFailed('Internal Error...No Sender Provided by GitHub')
|
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.
|
// 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)
|
if (isIssue && isPullRequest)
|
||||||
return core.setFailed(
|
return core.setFailed(
|
||||||
'Internal Error...Both Issue and PR Provided by GitHub'
|
'Internal Error...Both Issue and PR Provided by GitHub'
|
||||||
|
|||||||
Reference in New Issue
Block a user