Skip to content

Commit

Permalink
fix: merge status output not working (#571)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
simoneb and PhanindraNeralla authored Feb 9, 2024
1 parent d87c9c8 commit 0d14644
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 6 deletions.
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

0 comments on commit 0d14644

Please sign in to comment.