From ba70106399645cdf66a36736137dc135a843f830 Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Tue, 6 May 2025 10:25:02 +0200 Subject: [PATCH] Fix enforce_branch_name.yml --- .github/workflows/enforce_branch_name.yml | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/enforce_branch_name.yml b/.github/workflows/enforce_branch_name.yml index 7868426c..85035330 100644 --- a/.github/workflows/enforce_branch_name.yml +++ b/.github/workflows/enforce_branch_name.yml @@ -8,19 +8,6 @@ jobs: check-source-branch: runs-on: ubuntu-latest steps: - - name: Leave comment if PR is from master/main branch of fork - if: ${{ github.event.pull_request.head.repo.fork == 'true' && (github.event.pull_request.head.ref == 'master' || github.event.pull_request.head.ref == 'main') }} - uses: actions/github-script@v6 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - github.rest.issues.createComment({ - issue_number: context.issue.number, - owner: context.repo.owner, - repo: context.repo.repo, - body: '⚠️ **ERROR:** Pull requests from the `master`/`main` branch of forks are not allowed, because it prevents maintainers from contributing to your PR. Please create a feature branch in your fork and submit the PR from that branch instead.' - }) - - name: Check PR source branch run: | # Check if PR is from a fork @@ -32,3 +19,16 @@ jobs: exit 1 fi fi + + - name: Leave comment if PR is from master/main branch of fork d + if: ${{ failure() }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: '⚠️ **ERROR:** Pull requests from the `master`/`main` branch of forks are not allowed, because it prevents maintainers from contributing to your PR. Please create a feature branch in your fork and submit the PR from that branch instead.' + })