aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/main-pr.yml
blob: f68aaaf4a5663e5f81f30f9b4b5fac8059a6ffac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
name: Force to dev PRs not from dev to main
on:
  pull_request:
    types: [opened, edited, reopened, synchronize]
    branches:
      - 'main'
jobs:
  pr_to_main_from_dev:
    if: github.head_ref != 'dev'
    permissions:
      pull-requests: write
    runs-on: ubuntu-latest
    steps:
      - name: Add comment
        uses: peter-evans/create-or-update-comment@v4
        with:
          token: ${{ secrets.TOKEN_GITHUB }}
          issue-number: ${{ github.event.pull_request.number }}
          body: |
            Tried to create a pull request to `main` from a branch that isn't `dev`!
            **Changing destinaton branch to `dev`!**
      - name: Change base to dev
        run: gh pr edit $PR --base 'dev'
        env:
          GH_TOKEN: ${{ secrets.TOKEN_GITHUB }}
          PR: ${{ github.event.pull_request.html_url }}