Skip to content

Commit

Permalink
Lock down supported events to just dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
Barry Gordon committed Oct 18, 2021
1 parent 9d81537 commit 4171620
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 39 deletions.
17 changes: 0 additions & 17 deletions __tests__/inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,3 @@ test('loads dynamic', () => {
expect(params?.jobToken).toEqual('xxx')
expect(params?.credentialsToken).toEqual('yyy')
})

test('loads workflow_dispatch', () => {
const ctx = new Context()
ctx.eventName = 'workflow_dispatch'
ctx.payload = {
inputs: {
jobId: '1',
jobToken: 'xxx',
credentialsToken: 'yyy'
}
}

const params = getJobParameters(ctx)
expect(params?.jobId).toEqual(1)
expect(params?.jobToken).toEqual('xxx')
expect(params?.credentialsToken).toEqual('yyy')
})
14 changes: 7 additions & 7 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('run', () => {
describe('when the run follows the happy path', () => {
beforeAll(() => {
process.env.GITHUB_EVENT_PATH = eventFixturePath('default')
process.env.GITHUB_EVENT_NAME = 'workflow_dispatch'
process.env.GITHUB_EVENT_NAME = 'dynamic'
process.env.GITHUB_ACTOR = 'dependabot[bot]'
context = new Context()
})
Expand All @@ -62,7 +62,7 @@ describe('run', () => {
describe('when the action is triggered on by a different actor', () => {
beforeAll(() => {
process.env.GITHUB_EVENT_PATH = eventFixturePath('default')
process.env.GITHUB_EVENT_NAME = 'workflow_dispatch'
process.env.GITHUB_EVENT_NAME = 'dynamic'
process.env.GITHUB_ACTOR = 'classic-rando'
context = new Context()
})
Expand Down Expand Up @@ -118,7 +118,7 @@ describe('run', () => {
)

process.env.GITHUB_EVENT_PATH = eventFixturePath('default')
process.env.GITHUB_EVENT_NAME = 'workflow_dispatch'
process.env.GITHUB_EVENT_NAME = 'dynamic'
process.env.GITHUB_ACTOR = 'dependabot[bot]'
context = new Context()
})
Expand Down Expand Up @@ -150,7 +150,7 @@ describe('run', () => {
)

process.env.GITHUB_EVENT_PATH = eventFixturePath('default')
process.env.GITHUB_EVENT_NAME = 'workflow_dispatch'
process.env.GITHUB_EVENT_NAME = 'dynamic'
process.env.GITHUB_ACTOR = 'dependabot[bot]'
context = new Context()
})
Expand Down Expand Up @@ -182,7 +182,7 @@ describe('run', () => {
)

process.env.GITHUB_EVENT_PATH = eventFixturePath('default')
process.env.GITHUB_EVENT_NAME = 'workflow_dispatch'
process.env.GITHUB_EVENT_NAME = 'dynamic'
process.env.GITHUB_ACTOR = 'dependabot[bot]'
context = new Context()
})
Expand Down Expand Up @@ -219,7 +219,7 @@ describe('run', () => {
)

process.env.GITHUB_EVENT_PATH = eventFixturePath('default')
process.env.GITHUB_EVENT_NAME = 'workflow_dispatch'
process.env.GITHUB_EVENT_NAME = 'dynamic'
process.env.GITHUB_ACTOR = 'dependabot[bot]'
context = new Context()
})
Expand Down Expand Up @@ -256,7 +256,7 @@ describe('run', () => {
)

process.env.GITHUB_EVENT_PATH = eventFixturePath('default')
process.env.GITHUB_EVENT_NAME = 'workflow_dispatch'
process.env.GITHUB_EVENT_NAME = 'dynamic'
process.env.GITHUB_ACTOR = 'dependabot[bot]'
context = new Context()
})
Expand Down
13 changes: 7 additions & 6 deletions dist/main/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/main/index.js.map

Large diffs are not rendered by default.

17 changes: 9 additions & 8 deletions src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ import {Context} from '@actions/github/lib/context'
import {WorkflowDispatchEvent} from '@octokit/webhooks-types'
import {JobParameters} from './api-client'

const DYNAMIC = 'dynamic'

export function getJobParameters(ctx: Context): JobParameters | null {
switch (ctx.eventName) {
case 'dynamic':
case 'workflow_dispatch':
return fromWorkflowInputs(ctx)
if (ctx.eventName === DYNAMIC) {
return fromWorkflowInputs(ctx)
} else {
core.info(
`Dependabot Updater Action does not support '${ctx.eventName}' events.`
)
return null
}
core.info(
`Dependabot Updater Action does not support '${ctx.eventName}' events.`
)
return null
}

function fromWorkflowInputs(ctx: Context): JobParameters {
Expand Down

0 comments on commit 4171620

Please sign in to comment.