File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Block PRs to Master
2+
3+ on :
4+ pull_request :
5+ branches :
6+ - master
7+
8+ jobs :
9+ block :
10+ runs-on : ubuntu-latest
11+
12+ steps :
13+ - name : Check source branch and block if not develop
14+ uses : actions/github-script@v7
15+ with :
16+ script : |
17+ const sourceBranch = context.payload.pull_request.head.ref;
18+
19+ if (sourceBranch === 'develop') {
20+ console.log(`✅ PR de ${sourceBranch} para master permitido.`);
21+ return;
22+ }
23+
24+ await github.rest.issues.createComment({
25+ owner: context.repo.owner,
26+ repo: context.repo.repo,
27+ issue_number: context.issue.number,
28+ body: `❌ Pull Requests diretamente para **master** são permitidos apenas a partir da branch **develop**.
29+ Origem detectada: \`${sourceBranch}\`.
30+ Por favor, primeiro faça o merge da sua branch na \`develop\` e então abra um PR de \`develop\` para \`master\`.`
31+ });
32+
33+ await github.rest.pulls.update({
34+ owner: context.repo.owner,
35+ repo: context.repo.repo,
36+ pull_number: context.payload.pull_request.number,
37+ state: 'closed'
38+ });
You can’t perform that action at this time.
0 commit comments