-
Notifications
You must be signed in to change notification settings - Fork 966
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(workflows): users cannot perform merge action on their own PRs (#…
- Loading branch information
1 parent
a79dd93
commit 0f323e3
Showing
1 changed file
with
7 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,7 +36,7 @@ jobs: | |
with: | ||
private-key: ${{ secrets.ACTION_PRIVATE_KEY }} | ||
app-id: ${{ secrets.ACTION_APP_ID }} | ||
- name: Check | ||
- name: Reset | ||
if: "contains(github.event.pull_request.labels.*.name, 'action(squash-merge): failed')" | ||
uses: actions-ecosystem/[email protected] | ||
with: | ||
|
@@ -71,7 +71,7 @@ jobs: | |
fi | ||
- name: Squash | ||
id: squash | ||
if: ${{ !steps.commitlint.outputs.failed_result }} | ||
if: ${{ !steps.commitlint.outputs.failed_result && github.event.pull_request.user.login != github.event.sender.login }} | ||
env: | ||
GH_TOKEN: ${{ steps.get-token.outputs.token }} | ||
shell: bash {0} | ||
|
@@ -102,15 +102,18 @@ jobs: | |
with: | ||
github-token: ${{ steps.get-token.outputs.token }} | ||
script: | | ||
const { pull_request } = context.payload; | ||
const { pull_request, sender } = context.payload; | ||
const { issues } = github.rest; | ||
const util = require('util'); | ||
const os = require('os'); | ||
let body; | ||
if (process.env.CHECK_RESULT) { | ||
body = util.format(process.env.FAILED_MESSAGE, 'pull request title does not meet the [Convention Commit](https://conventionalcommits.org/) guideline', process.env.CHECK_RESULT); | ||
} else if (process.env.SQUASH_RESULT) { | ||
body = util.format(process.env.FAILED_MESSAGE, 'auto squash and merge failed', process.env.SQUASH_RESULT); | ||
} else if (pull_request.user.login === sender.login) { | ||
body = util.format(process.env.FAILED_MESSAGE, 'cannot squash and merge your own pull request', `(empty response)`); | ||
} | ||
const p = []; | ||
|