Skip to content

Commit

Permalink
getMessage can skip commit verification checks
Browse files Browse the repository at this point in the history
  • Loading branch information
brrygrdn committed Jun 30, 2022
1 parent bfac3fa commit 29dc6db
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions src/dependabot/verified_commits.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ test('it returns false if the commit is has no verification payload', async () =
expect(await getMessage(mockGitHubClient, mockGitHubPullContext())).toBe(false)
})

test('it returns the message if the commit is has no verification payload but verification is skipped', async () => {
nock('https://api.github.com').get('/repos/dependabot/dependabot/pulls/101/commits')
.reply(200, [
{
author: {
login: 'dependabot[bot]'
},
commit: {
message: 'Bump lodash from 1.0.0 to 2.0.0',
verification: null
}
}
])

expect(await getMessage(mockGitHubClient, mockGitHubPullContext(), true)).toEqual('Bump lodash from 1.0.0 to 2.0.0')
})

test('it returns false if the commit is not verified', async () => {
nock('https://api.github.com').get('/repos/dependabot/dependabot/pulls/101/commits')
.reply(200, [
Expand Down
4 changes: 2 additions & 2 deletions src/dependabot/verified_commits.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import https from 'https'

const DEPENDABOT_LOGIN = 'dependabot[bot]'

export async function getMessage (client: InstanceType<typeof GitHub>, context: Context): Promise<string | false> {
export async function getMessage (client: InstanceType<typeof GitHub>, context: Context, skipCommitVerification = false): Promise<string | false> {
core.debug('Verifying the job is for an authentic Dependabot Pull Request')

const { pull_request: pr } = context.payload
Expand Down Expand Up @@ -43,7 +43,7 @@ export async function getMessage (client: InstanceType<typeof GitHub>, context:
return false
}

if (!commit.verification?.verified) {
if (!skipCommitVerification && !commit.verification?.verified) {
// TODO: Promote to setFailed
core.warning(
"Dependabot's commit signature is not verified, refusing to proceed."
Expand Down

0 comments on commit 29dc6db

Please sign in to comment.