Skip to content

Commit

Permalink
fix: don't fail versioning because auto-merge failed to enable (#50)
Browse files Browse the repository at this point in the history
  • Loading branch information
sparten11740 authored Jun 28, 2024
1 parent fba4c3a commit d71ceb4
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 41 deletions.
44 changes: 33 additions & 11 deletions dist/publish/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/publish/index.js.map

Large diffs are not rendered by default.

27 changes: 16 additions & 11 deletions dist/version/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/version/index.js.map

Large diffs are not rendered by default.

41 changes: 24 additions & 17 deletions src/utils/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as core from '@actions/core'
import * as github from '@actions/github'

import { Repo } from './types'
import { unwrapErrorMessage } from './errors'

export type GithubClient = ReturnType<typeof github.getOctokit>

Expand Down Expand Up @@ -85,29 +86,35 @@ export async function createPullRequest({
}

if (autoMerge) {
const autoMergePromise = client.graphql<EnablePullRequestAutoMergeResponse>(
/* GraphQL */ `
mutation EnableAutoMerge($pullRequestId: ID!) {
enablePullRequestAutoMerge(
input: { pullRequestId: $pullRequestId, mergeMethod: SQUASH }
) {
pullRequest {
autoMergeRequest {
enabledAt
const autoMergePromise = client
.graphql<EnablePullRequestAutoMergeResponse>(
/* GraphQL */ `
mutation EnableAutoMerge($pullRequestId: ID!) {
enablePullRequestAutoMerge(
input: { pullRequestId: $pullRequestId, mergeMethod: SQUASH }
) {
pullRequest {
autoMergeRequest {
enabledAt
}
}
}
}
`,
{
pullRequestId: response.data.node_id,
}
`,
{
pullRequestId: response.data.node_id,
}
)
)
.then(({ enablePullRequestAutoMerge: { pullRequest } }) =>
core.debug(`Auto-merge enabled at ${pullRequest.autoMergeRequest.enabledAt}`)
)
.catch((error) => {
core.warning(
`Failed to enable auto-merge: ${unwrapErrorMessage(error, 'for unknown reasons')}`
)
})

promises.push(autoMergePromise)
autoMergePromise.then(({ enablePullRequestAutoMerge: { pullRequest } }) =>
core.debug(`Auto-merge enabled at ${pullRequest.autoMergeRequest.enabledAt}`)
)
}

await Promise.all(promises)
Expand Down

0 comments on commit d71ceb4

Please sign in to comment.