Skip to content

Commit 374ace8

Browse files
committed
[feature/releaser] Automate assigning/unassigning issues #571
I've created four GitHub Actions workflow files to automate issue assignment/unassignment. Created Workflows: 1. issue-assignment.yml – Auto-response to 'assign me' requests 2. pr-issue-link.yml – Auto-assign on PR 3. stale-pr-management.yml – Stale PR management (tracks contributor inactivity only) 4. pr-reopen-reassign.yml – Handle contributor follow-up Fixes #571
1 parent d9d85c3 commit 374ace8

File tree

14 files changed

+2063
-0
lines changed

14 files changed

+2063
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Issue Assignment Bot
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
permissions:
8+
issues: write
9+
10+
jobs:
11+
respond-to-assign-request:
12+
runs-on: ubuntu-latest
13+
if: github.event.issue.pull_request == null
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.9"
22+
23+
- name: Install dependencies
24+
run: pip install -e .[bots]
25+
26+
- name: Run issue assignment bot
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
REPOSITORY: ${{ github.repository }}
30+
GITHUB_EVENT_NAME: ${{ github.event_name }}
31+
EVENT_DATA: ${{ toJson(github.event) }}
32+
run: |
33+
echo "$EVENT_DATA" > event.json
34+
python -m openwisp_utils.bots.auto_assign issue_assignment event.json
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
name: PR Issue Auto-Assignment
2+
3+
on:
4+
pull_request_target:
5+
types: [opened, reopened]
6+
7+
permissions:
8+
issues: write
9+
pull-requests: read
10+
11+
jobs:
12+
auto-assign-issue:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
18+
- name: Set up Python
19+
uses: actions/setup-python@v5
20+
with:
21+
python-version: "3.9"
22+
23+
- name: Install dependencies
24+
run: pip install -e .[bots]
25+
26+
- name: Run issue assignment bot
27+
env:
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
29+
REPOSITORY: ${{ github.repository }}
30+
GITHUB_EVENT_NAME: ${{ github.event_name }}
31+
run: |
32+
echo '${{ toJson(github.event) }}' > event.json
33+
python -m openwisp_utils.bots.auto_assign issue_assignment event.json
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: PR Reopen Reassignment
2+
3+
on:
4+
pull_request_target:
5+
types: [reopened]
6+
issue_comment:
7+
types: [created]
8+
9+
permissions:
10+
issues: write
11+
pull-requests: read
12+
13+
jobs:
14+
reassign-on-reopen:
15+
runs-on: ubuntu-latest
16+
if: github.event_name == 'pull_request_target' && github.event.action == 'reopened'
17+
steps:
18+
- name: Checkout repository
19+
uses: actions/checkout@v4
20+
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.9"
25+
26+
- name: Install dependencies
27+
run: pip install -e .[bots]
28+
29+
- name: Reassign issues on PR reopen
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
REPOSITORY: ${{ github.repository }}
33+
GITHUB_EVENT_NAME: ${{ github.event_name }}
34+
run: |
35+
echo '${{ toJson(github.event) }}' > event.json
36+
python -m openwisp_utils.bots.auto_assign pr_reopen event.json
37+
38+
handle-pr-activity:
39+
runs-on: ubuntu-latest
40+
if: github.event_name == 'issue_comment' && github.event.issue.pull_request
41+
steps:
42+
- name: Checkout repository
43+
uses: actions/checkout@v4
44+
45+
- name: Set up Python
46+
uses: actions/setup-python@v5
47+
with:
48+
python-version: "3.9"
49+
50+
- name: Install dependencies
51+
run: pip install -e .[bots]
52+
53+
- name: Handle PR activity
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
56+
REPOSITORY: ${{ github.repository }}
57+
GITHUB_EVENT_NAME: ${{ github.event_name }}
58+
run: |
59+
echo '${{ toJson(github.event) }}' > event.json
60+
python -m openwisp_utils.bots.auto_assign pr_reopen event.json
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Stale PR Management
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
8+
permissions:
9+
issues: write
10+
pull-requests: write
11+
12+
jobs:
13+
manage-stale-prs-python:
14+
runs-on: ubuntu-latest
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
python-version: "3.9"
23+
24+
- name: Install dependencies
25+
run: pip install -e .[bots]
26+
27+
- name: Run stale PR bot
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
REPOSITORY: ${{ github.repository }}
31+
run: python -m openwisp_utils.bots.auto_assign stale_pr

openwisp_utils/bots/__init__.py

Whitespace-only changes.

openwisp_utils/bots/auto_assign/__init__.py

Whitespace-only changes.
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
5+
6+
def main():
7+
"""Entry point for all bot functionality"""
8+
if len(sys.argv) < 2:
9+
print("Usage: python -m openwisp_utils.bots.auto_assign <bot_type> [args...]")
10+
print("Available bot types: issue_assignment, stale_pr, pr_reopen")
11+
return 1
12+
13+
bot_type = sys.argv[1]
14+
15+
try:
16+
if bot_type == "issue_assignment":
17+
from .issue_assignment_bot import main as issue_main
18+
19+
sys.argv = [sys.argv[0]] + sys.argv[2:]
20+
issue_main()
21+
elif bot_type == "stale_pr":
22+
from .stale_pr_bot import main as stale_main
23+
24+
stale_main()
25+
elif bot_type == "pr_reopen":
26+
from .pr_reopen_bot import main as pr_main
27+
28+
sys.argv = [sys.argv[0]] + sys.argv[2:]
29+
pr_main()
30+
else:
31+
print(f"Unknown bot type: {bot_type}")
32+
print("Available bot types: issue_assignment, stale_pr, pr_reopen")
33+
return 1
34+
35+
return 0
36+
except Exception as e:
37+
print(f"Error running {bot_type} bot: {e}")
38+
return 1
39+
40+
41+
if __name__ == "__main__":
42+
sys.exit(main())

0 commit comments

Comments
 (0)