Skip to content

Commit

Permalink
Merge pull request #17 from github/link-to-blog-post
Browse files Browse the repository at this point in the history
add a link to the GitHub blog post for Actions + PR creation
  • Loading branch information
GrantBirki committed Apr 1, 2023
2 parents 110b2c1 + 843990d commit 89b872b
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
14 changes: 12 additions & 2 deletions __tests__/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,13 @@ test('runs the action and fails to create a pull request', async () => {
})
},
pulls: {
create: jest.fn().mockRejectedValueOnce(new BigBadError('Oh no!')),
create: jest
.fn()
.mockRejectedValueOnce(
new BigBadError(
'GitHub Actions is not permitted to create or approve pull requests'
)
),
list: jest.fn().mockReturnValueOnce({
data: [
{
Expand All @@ -513,8 +519,12 @@ test('runs the action and fails to create a pull request', async () => {

expect(await run()).toBe('failure')

expect(warningMock).toHaveBeenCalledWith(
'https://github.blog/changelog/2022-05-03-github-actions-prevent-github-actions-from-creating-and-approving-pull-requests/'
)

expect(setFailedMock).toHaveBeenCalledWith(
'Failed to create combined PR - Error: Oh no!'
'Failed to create combined PR - Error: GitHub Actions is not permitted to create or approve pull requests'
)
})

Expand Down
10 changes: 10 additions & 0 deletions dist/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/index.js.map

Large diffs are not rendered by default.

10 changes: 10 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,16 @@ export async function run() {
})
pullRequest = {data: pr}
} else {
if (
error?.message?.includes(
'GitHub Actions is not permitted to create or approve pull requests'
)
) {
core.warning(
'https://github.blog/changelog/2022-05-03-github-actions-prevent-github-actions-from-creating-and-approving-pull-requests/'
)
}

core.setFailed(`Failed to create combined PR - ${error}`)
return 'failure'
}
Expand Down

0 comments on commit 89b872b

Please sign in to comment.