Skip to content

Commit db3bd8a

Browse files
authored
Merge pull request #953 from opentensor/sam-hotfix-warnings
add bot warning when posting a hotfix PR
2 parents 82664af + ee4bc00 commit db3bd8a

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

.github/workflows/hotfixes.yml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Handle Hotfix PRs
2+
3+
on:
4+
pull_request:
5+
types: [opened]
6+
7+
permissions:
8+
pull-requests: write
9+
contents: write
10+
11+
jobs:
12+
handle-hotfix-pr:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Check if PR is a hotfix into `main`
16+
if: >
17+
github.event.pull_request.base.ref == 'main' &&
18+
github.event.pull_request.head.ref != 'testnet'
19+
run: |
20+
echo "Hotfix PR detected. Proceeding to label and comment."
21+
22+
- name: Add `hotfix` label
23+
if: >
24+
github.event.pull_request.base.ref == 'main' &&
25+
github.event.pull_request.head.ref != 'testnet'
26+
run: |
27+
curl -X POST \
28+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
29+
-H "Accept: application/vnd.github.v3+json" \
30+
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels \
31+
-d '{"labels":["hotfix"]}'
32+
33+
- name: Add hotfix bot comment
34+
if: >
35+
github.event.pull_request.base.ref == 'main' &&
36+
github.event.pull_request.head.ref != 'testnet'
37+
run: |
38+
COMMENT_BODY=$(cat <<EOF
39+
## 🚨🚨🚨 HOTFIX DETECTED 🚨🚨🚨
40+
41+
It looks like you are trying to merge a hotfix PR into `main`. If this isn't what you wanted to do, and you just wanted to make a regular PR, please close this PR, base your changes off the `devnet-ready` branch and open a new PR into `devnet ready`.
42+
43+
If you _are_ trying to merge a hotfix PR, please complete the following essential steps:
44+
1. [ ] go ahead and get this PR into `main` merged, so we can get the change in as quickly as possible!
45+
2. [ ] merge `main` into `testnet`, bumping `spec_version`
46+
3. [ ] deploy `testnet`
47+
4. [ ] merge `testnet` into `devnet`, bumping `spec_version`
48+
5. [ ] deploy `devnet`
49+
6. [ ] merge `devnet` into `devnet-ready`
50+
51+
52+
If you do not complete these steps, your hotfix may be inadvertently removed in the future when branches are promoted to \`main\`, so it is essential that you do so.
53+
EOF
54+
)
55+
56+
curl -X POST \
57+
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
58+
-H "Accept: application/vnd.github.v3+json" \
59+
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
60+
-d "$(jq -n --arg body "$COMMENT_BODY" '{body: $body}')"
61+
env:
62+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)