-
-
Notifications
You must be signed in to change notification settings - Fork 7
116 lines (93 loc) · 3.83 KB
/
bug-sync.yml
File metadata and controls
116 lines (93 loc) · 3.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Bug Sync Automation
on:
push:
paths:
- 'docs/bugs/**'
branches:
- main
- feature/*
issues:
types: [opened, edited, closed, labeled]
jobs:
sync-bugs:
if: contains(github.event.issue.labels.*.name, 'bug') || github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
issues: write
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install GitHub CLI
run: |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh
- name: Configure GitHub CLI
run: |
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token
- name: Sync new local bugs to GitHub
if: github.event_name == 'push'
run: |
# Check for new bug files in the push
git diff --name-only ${{ github.event.before }} ${{ github.event.after }} | grep "^docs/bugs/BUG-.*\.md$" || exit 0
# Run sync automation
python scripts/bug-sync-automation.py --sync-to-github
# Commit any updates to bug files
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
if git diff --quiet; then
echo "No changes to commit"
else
git add docs/bugs/
git commit -m "Auto-sync: Update bug files with GitHub issue references
🤖 Generated with GitHub Actions"
git push
fi
- name: Update local bug file when GitHub issue changes
if: github.event_name == 'issues'
run: |
# Extract bug ID from issue title
ISSUE_TITLE="${{ github.event.issue.title }}"
BUG_ID=$(echo "$ISSUE_TITLE" | grep -o "BUG-[0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}-[0-9]\+" || echo "")
if [ -z "$BUG_ID" ]; then
echo "No bug ID found in issue title: $ISSUE_TITLE"
exit 0
fi
# Find corresponding local bug file
BUG_FILE=$(find docs/bugs/ -name "$BUG_ID-*.md" | head -1)
if [ -z "$BUG_FILE" ]; then
echo "No local bug file found for $BUG_ID"
exit 0
fi
echo "Updating $BUG_FILE based on GitHub issue #${{ github.event.issue.number }}"
# Update Last Sync date in the bug file
TODAY=$(date '+%Y-%m-%d')
sed -i "s/\*\*Last Sync\*\*:.*/\*\*Last Sync\*\*: $TODAY/" "$BUG_FILE"
# If issue was closed, add comment about GitHub status
if [ "${{ github.event.action }}" = "closed" ]; then
echo "" >> "$BUG_FILE"
echo "**GitHub Update ($TODAY)**: Issue #${{ github.event.issue.number }} was closed on GitHub" >> "$BUG_FILE"
fi
# Commit changes
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
if git diff --quiet; then
echo "No changes to commit"
else
git add "$BUG_FILE"
git commit -m "Auto-sync: Update $BUG_ID from GitHub issue #${{ github.event.issue.number }}
🤖 Generated with GitHub Actions"
git push
fi
- name: Validate bug sync status
run: |
python scripts/bug-sync-automation.py --validate