Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: merge status output not working #571

Merged
merged 5 commits into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ Error: Resource not accessible by integration

## Output

| outputs | Description |
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| merge_status | The result status of the merge. It can be one of the following: `approved`, `merged`, `merge_failed`, `skipped:commit_verification_failed`, `skipped:not_a_dependabot_pr`, `skipped:cannot_update_major`, `skipped:bump_higher_than_target`, `skipped:packaged_excluded` |
| outputs | Description |
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| merge_status | The result status of the merge. It can be one of the following: `approved`, `merged`, `auto_merge`, `merge_failed`, `skipped:commit_verification_failed`, `skipped:not_a_dependabot_pr`, `skipped:cannot_update_major`, `skipped:bump_higher_than_target`, `skipped:packaged_excluded` |

## Examples

Expand Down
8 changes: 7 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ inputs:
description: 'If true, the action will not validate the user or the commit verification status'
default: false

outputs:
merge_status:
description: 'Merge status'
value: ${{ steps.approver.outputs.merge_status }}

runs:
using: 'composite'
steps:
Expand All @@ -56,9 +61,10 @@ runs:
if: github.event_name == 'pull_request' && (github.actor == 'dependabot[bot]' || inputs.skip-verification == 'true')
with:
skip-commit-verification: ${{ inputs.skip-commit-verification }}
skip-verification : ${{ inputs.skip-verification }}
skip-verification: ${{ inputs.skip-verification }}
- name: Merge/approve PR
uses: actions/github-script@v7
id: approver
with:
github-token: ${{ inputs.github-token }}
script: |
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2906,7 +2906,6 @@ module.exports = async function run({
toolkit.logActionRefWarning()

const { pull_request } = context.payload

if (!pull_request && !PR_NUMBER) {
core.setOutput(MERGE_STATUS_KEY, MERGE_STATUS.skippedNotADependabotPr)
return logError(
Expand Down Expand Up @@ -3005,6 +3004,7 @@ ${changedExcludedPackages.join(', ')}. Skipping.`)

if (USE_GITHUB_AUTO_MERGE) {
await client.enableAutoMergePullRequest(pr.node_id, MERGE_METHOD)
core.setOutput(MERGE_STATUS_KEY, MERGE_STATUS.autoMerge)
return logInfo('USE_GITHUB_AUTO_MERGE set, PR was marked as auto-merge')
}

Expand Down Expand Up @@ -3281,6 +3281,7 @@ exports.getTarget = (
exports.MERGE_STATUS = {
approved: 'approved',
merged: 'merged',
autoMerge: 'auto_merge',
mergeFailed: 'merge_failed',
skippedCommitVerificationFailed: 'skipped:commit_verification_failed',
skippedNotADependabotPr: 'skipped:not_a_dependabot_pr',
Expand Down
2 changes: 1 addition & 1 deletion src/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ module.exports = async function run({
toolkit.logActionRefWarning()

const { pull_request } = context.payload

if (!pull_request && !PR_NUMBER) {
core.setOutput(MERGE_STATUS_KEY, MERGE_STATUS.skippedNotADependabotPr)
return logError(
Expand Down Expand Up @@ -146,6 +145,7 @@ ${changedExcludedPackages.join(', ')}. Skipping.`)

if (USE_GITHUB_AUTO_MERGE) {
await client.enableAutoMergePullRequest(pr.node_id, MERGE_METHOD)
core.setOutput(MERGE_STATUS_KEY, MERGE_STATUS.autoMerge)
return logInfo('USE_GITHUB_AUTO_MERGE set, PR was marked as auto-merge')
}

Expand Down
1 change: 1 addition & 0 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ exports.getTarget = (
exports.MERGE_STATUS = {
approved: 'approved',
merged: 'merged',
autoMerge: 'auto_merge',
mergeFailed: 'merge_failed',
skippedCommitVerificationFailed: 'skipped:commit_verification_failed',
skippedNotADependabotPr: 'skipped:not_a_dependabot_pr',
Expand Down
5 changes: 5 additions & 0 deletions test/action.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,11 @@ tap.test('should review and enable github auto-merge', async () => {
sinon.assert.notCalled(stubs.coreStub.setFailed)
sinon.assert.calledOnce(stubs.approveStub)
sinon.assert.calledOnce(stubs.enableAutoMergeStub)
sinon.assert.calledWith(
stubs.coreStub.setOutput,
MERGE_STATUS_KEY,
MERGE_STATUS.autoMerge,
)
})

tap.test('should forbid major when target is minor', async () => {
Expand Down
Loading