Skip to content

Commit 2a26d55

Browse files
authored
Create live-protection.yml
1 parent 132153d commit 2a26d55

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on: [pull_request]
2+
3+
permissions:
4+
contents: read
5+
6+
jobs:
7+
comment:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Harden Runner
11+
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
12+
with:
13+
egress-policy: audit
14+
15+
- uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea
16+
env:
17+
SHOULD_COMMENT: ${{ github.base_ref == 'refs/heads/live' && !(github.head_ref == 'refs/heads/main') }}
18+
with:
19+
script: |
20+
if (process.env.SHOULD_COMMENT == 'true') {
21+
github.issues.createComment({
22+
issue_number: context.issue.number,
23+
owner: context.repo.owner,
24+
repo: context.repo.repo,
25+
body: 'It looks like this pull request may have been opened on the `live` branch by mistake. In general, PRs should target the `main` branch.'
26+
})
27+
}

0 commit comments

Comments
 (0)