diff --git a/README.md b/README.md index af7db12..d275c35 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/action.yml b/action.yml index 1ce6051..64966fc 100644 --- a/action.yml +++ b/action.yml @@ -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: @@ -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: | diff --git a/dist/index.js b/dist/index.js index abb6d24..f18f629 100644 --- a/dist/index.js +++ b/dist/index.js @@ -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( @@ -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') } @@ -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', diff --git a/src/action.js b/src/action.js index c2e48f7..82b0b7d 100644 --- a/src/action.js +++ b/src/action.js @@ -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( @@ -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') } diff --git a/src/util.js b/src/util.js index 08b133a..45e40f7 100644 --- a/src/util.js +++ b/src/util.js @@ -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', diff --git a/test/action.test.js b/test/action.test.js index 0391cf9..801e6b8 100644 --- a/test/action.test.js +++ b/test/action.test.js @@ -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 () => {