Skip to content

Commit 5daf073

Browse files
kRHYME7rubiin
authored andcommitted
ci: try fix warns on master
1 parent 20d1dd7 commit 5daf073

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

.github/workflows/warn-master-pr.yml

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,39 @@
11
name: Warn Master Branch PR
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
types: [opened, reopened, synchronize]
66

77
jobs:
88
warn-master-branch-pr:
99
name: Warn about PR targeting master branch
10-
if: github.event.pull_request.base.ref == 'master'
1110
runs-on: ubuntu-latest
11+
permissions:
12+
issues: write
13+
pull-requests: write
1214
steps:
15+
- name: Debug PR info
16+
uses: actions/github-script@v6
17+
with:
18+
github-token: ${{ secrets.GITHUB_TOKEN }}
19+
script: |
20+
console.log('=== PR DEBUG INFO ===');
21+
console.log('Base ref:', context.payload.pull_request.base.ref);
22+
console.log('Head ref:', context.payload.pull_request.head.ref);
23+
console.log('Base repo:', context.payload.pull_request.base.repo.full_name);
24+
console.log('Head repo:', context.payload.pull_request.head.repo?.full_name);
25+
console.log('PR author:', context.payload.pull_request.user.login);
26+
console.log('PR number:', context.payload.pull_request.number);
27+
console.log('=== END DEBUG ===');
28+
1329
- name: Add warning comment
30+
if: github.event.pull_request.base.ref == 'master'
1431
uses: actions/github-script@v6
1532
with:
1633
github-token: ${{ secrets.GITHUB_TOKEN }}
1734
script: |
1835
const { repo, owner } = context.repo;
19-
const issue_number = context.issue.number;
36+
const issue_number = context.payload.pull_request.number;
2037
2138
// Skip if the PR author is github-actions[bot] (automated PR)
2239
const prAuthor = context.payload.pull_request.user.login;
@@ -25,7 +42,9 @@ jobs:
2542
return;
2643
}
2744
28-
// Check if we already commented on this PR
45+
console.log(`Processing PR #${issue_number} from ${prAuthor}`);
46+
47+
// Check if we already commented
2948
const comments = await github.rest.issues.listComments({
3049
owner,
3150
repo,
@@ -42,7 +61,7 @@ jobs:
4261
owner,
4362
repo,
4463
issue_number,
45-
body: "⚠️ **Warning: PR targeting master branch detected!**\n\n**This PR is targeting `master` but should target `dev` instead.**\n\nAccording to our [CONTRIBUTING.md](https://github.com/HyDE-Project/HyDE/blob/master/CONTRIBUTING.md) and [RELEASE_POLICY.md](https://github.com/HyDE-Project/HyDE/blob/master/RELEASE_POLICY.md):\n\n- **All pull requests must be submitted to the `dev` branch**\n- Changes go through `dev` first for testing before being merged to `master` during release windows\n- **PRs to `master` are only allowed for emergencies**\n\n**Required Action:**\n1. **Rebase this PR to target the `dev` branch instead**\n2. Update the base branch from `master` to `dev`\n3. Follow the [pull request template](https://github.com/HyDE-Project/HyDE/blob/master/.github/PULL_REQUEST_TEMPLATE.md)\n\n**If this is an emergency fix, please add a comment explaining why it needs to target `master` directly.**\n\n---\n*This is an automated message enforcing our contribution workflow.*"
64+
body: "⚠️ **Warning: PR targeting master branch detected!**\n\n**This PR is targeting `master` but should target `dev` instead.**\n\nAccording to our [CONTRIBUTING.md](https://github.com/HyDE-Project/HyDE/blob/master/CONTRIBUTING.md) and [RELEASE_POLICY.md](https://github.com/HyDE-Project/HyDE/blob/master/RELEASE_POLICY.md):\n\n- **All pull requests must be submitted to the `dev` branch**\n- Changes go through `dev` first for testing before being merged to `master` during release windows\n- **PRs to `master` are only allowed for emergencies**\n\n**Required Action:**\n1. **Change the base branch from `master` to `dev`**\n2. Follow the [pull request template](https://github.com/HyDE-Project/HyDE/blob/master/.github/PULL_REQUEST_TEMPLATE.md)\n\n**If this is an emergency fix, please add a comment explaining why it needs to target `master` directly.**\n\n---\n*This is an automated message enforcing our contribution workflow.*"
4665
});
4766
console.log('Warning comment added to PR #' + issue_number);
4867
} else {

0 commit comments

Comments
 (0)