Skip to content

Commit

Permalink
feat(workflows): users cannot perform merge action on their own PRs (T…
Browse files Browse the repository at this point in the history
  • Loading branch information
medns authored and pba-cra committed Feb 1, 2023
1 parent f058831 commit 0197c40
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/gh_action_merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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 = [];
Expand Down

0 comments on commit 0197c40

Please sign in to comment.