From d72df7864c3451fc94d4d8f673b6f5c139f175d0 Mon Sep 17 00:00:00 2001 From: Binrui Dong Date: Mon, 21 Nov 2022 00:16:37 +0800 Subject: [PATCH] Post a warning if a pull request is created from the master branch (#62237) --- .github/workflows/check-branch-name.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/check-branch-name.yml diff --git a/.github/workflows/check-branch-name.yml b/.github/workflows/check-branch-name.yml new file mode 100644 index 0000000000000..57a6a908256f4 --- /dev/null +++ b/.github/workflows/check-branch-name.yml @@ -0,0 +1,24 @@ +name: Check pull request head branch name + +on: + pull_request_target: + types: + - opened + +jobs: + check_branch_name: + runs-on: ubuntu-latest + if: github.head_ref == 'master' && github.repository == 'CleverRaven/Cataclysm-DDA' + steps: + - name: Post warning + uses: actions/github-script@v6.3.3 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: "You are creating a pull request with the master branch as the head branch. This is likely a mistake unless you really know what you are doing. You may read https://docs.github.com/en/get-started/quickstart/contributing-to-projects#creating-a-branch-to-work-on for a typical workflow of contributing to a project on GitHub." + }); +