Skip to content

Commit 0d14644

Browse files
fix: merge status output not working (#571)
* fix: merge status output not working * Dependabot/output doesnot seem to appear#539 (#574) * Fixes dependabot/output-doesnot-seem-to-appear#539 * #539 adding random merge status key to verify * #539 adding random merge status keys * #539 removed log messages. Added workflow id to workflow * #539 added workflow id to action yaml * #539 removed unneeded changes in action yaml file * fix #539 added new merge status for auto merge * #539 added testcase for auto merge (#576) * chore: rename main to approver in workflow --------- Co-authored-by: Phanindra Neralla <158252118+PhanindraNeralla@users.noreply.github.com>
1 parent d87c9c8 commit 0d14644

File tree

6 files changed

+19
-6
lines changed

6 files changed

+19
-6
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ Error: Resource not accessible by integration
3737

3838
## Output
3939

40-
| outputs | Description |
41-
| ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
42-
| 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` |
40+
| outputs | Description |
41+
| ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
42+
| 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` |
4343

4444
## Examples
4545

action.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ inputs:
4747
description: 'If true, the action will not validate the user or the commit verification status'
4848
default: false
4949

50+
outputs:
51+
merge_status:
52+
description: 'Merge status'
53+
value: ${{ steps.approver.outputs.merge_status }}
54+
5055
runs:
5156
using: 'composite'
5257
steps:
@@ -56,9 +61,10 @@ runs:
5661
if: github.event_name == 'pull_request' && (github.actor == 'dependabot[bot]' || inputs.skip-verification == 'true')
5762
with:
5863
skip-commit-verification: ${{ inputs.skip-commit-verification }}
59-
skip-verification : ${{ inputs.skip-verification }}
64+
skip-verification: ${{ inputs.skip-verification }}
6065
- name: Merge/approve PR
6166
uses: actions/github-script@v7
67+
id: approver
6268
with:
6369
github-token: ${{ inputs.github-token }}
6470
script: |

dist/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2906,7 +2906,6 @@ module.exports = async function run({
29062906
toolkit.logActionRefWarning()
29072907

29082908
const { pull_request } = context.payload
2909-
29102909
if (!pull_request && !PR_NUMBER) {
29112910
core.setOutput(MERGE_STATUS_KEY, MERGE_STATUS.skippedNotADependabotPr)
29122911
return logError(
@@ -3005,6 +3004,7 @@ ${changedExcludedPackages.join(', ')}. Skipping.`)
30053004

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

@@ -3281,6 +3281,7 @@ exports.getTarget = (
32813281
exports.MERGE_STATUS = {
32823282
approved: 'approved',
32833283
merged: 'merged',
3284+
autoMerge: 'auto_merge',
32843285
mergeFailed: 'merge_failed',
32853286
skippedCommitVerificationFailed: 'skipped:commit_verification_failed',
32863287
skippedNotADependabotPr: 'skipped:not_a_dependabot_pr',

src/action.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ module.exports = async function run({
4747
toolkit.logActionRefWarning()
4848

4949
const { pull_request } = context.payload
50-
5150
if (!pull_request && !PR_NUMBER) {
5251
core.setOutput(MERGE_STATUS_KEY, MERGE_STATUS.skippedNotADependabotPr)
5352
return logError(
@@ -146,6 +145,7 @@ ${changedExcludedPackages.join(', ')}. Skipping.`)
146145

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

src/util.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ exports.getTarget = (
7171
exports.MERGE_STATUS = {
7272
approved: 'approved',
7373
merged: 'merged',
74+
autoMerge: 'auto_merge',
7475
mergeFailed: 'merge_failed',
7576
skippedCommitVerificationFailed: 'skipped:commit_verification_failed',
7677
skippedNotADependabotPr: 'skipped:not_a_dependabot_pr',

test/action.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -631,6 +631,11 @@ tap.test('should review and enable github auto-merge', async () => {
631631
sinon.assert.notCalled(stubs.coreStub.setFailed)
632632
sinon.assert.calledOnce(stubs.approveStub)
633633
sinon.assert.calledOnce(stubs.enableAutoMergeStub)
634+
sinon.assert.calledWith(
635+
stubs.coreStub.setOutput,
636+
MERGE_STATUS_KEY,
637+
MERGE_STATUS.autoMerge,
638+
)
634639
})
635640

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

0 commit comments

Comments
 (0)