forked from homeassistant-ai/ha-mcp
-
Notifications
You must be signed in to change notification settings - Fork 0
143 lines (115 loc) · 4.9 KB
/
Copy pathnotify-dev-channel.yml
File metadata and controls
143 lines (115 loc) · 4.9 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
name: Notify Dev Channel on Merge
on:
push:
branches: [master]
paths:
- 'src/**'
permissions:
contents: read
pull-requests: write
issues: write
jobs:
notify:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 10
- name: Find merged PR and linked issues
id: find-pr
env:
GH_TOKEN: ${{ github.token }}
run: |
# Get the commit message
COMMIT_MSG=$(git log -1 --pretty=%B)
echo "Commit message: $COMMIT_MSG"
# Extract PR number from commit message
# GitHub merge commits have format: "Merge pull request #123 from user/branch"
# GitHub squash merges have format: "Title with (#123)" in first line
# Take only the first match to avoid capturing PR references in the title
PR_NUM=$(echo "$COMMIT_MSG" | head -1 | grep -oP '(?:Merge pull request #|[[(]#)\K\d+' | head -1 || echo "")
if [ -z "$PR_NUM" ]; then
echo "No PR number found in commit message. Skipping notification."
echo "skip=true" >> $GITHUB_OUTPUT
exit 0
fi
echo "Found PR #$PR_NUM"
echo "pr_number=$PR_NUM" >> $GITHUB_OUTPUT
echo "skip=false" >> $GITHUB_OUTPUT
# Get PR body to find linked issues
PR_BODY=$(gh pr view $PR_NUM --json body --jq '.body // ""')
# Extract issue numbers from various closing keywords
# Matches: Closes #123, Fixes #456, Resolves #789, Fix #101, Close #102, etc.
ISSUES=$(echo "$PR_BODY" | grep -oiP '(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s*#\K\d+' | sort -u | tr '\n' ',' | sed 's/,$//')
echo "Linked issues: $ISSUES"
echo "issues=$ISSUES" >> $GITHUB_OUTPUT
- name: Comment on merged PR
if: steps.find-pr.outputs.skip != 'true' && steps.find-pr.outputs.pr_number
env:
GH_TOKEN: ${{ github.token }}
run: |
gh pr comment ${{ steps.find-pr.outputs.pr_number }} --body "$(cat <<'EOF'
## 🧪 Your changes are now in the dev channel!
Your PR has been merged to master and is available for testing in the **dev channel**.
**Test your changes before the Tuesday release:**
📖 **[Dev Channel Documentation](https://github.com/homeassistant-ai/ha-mcp/blob/master/docs/dev-channel.md)**
### Quick start
```bash
# Run dev version
uvx ha-mcp-dev
# Check version
uvx ha-mcp-dev --version
```
**Docker:**
```bash
docker pull ghcr.io/homeassistant-ai/ha-mcp:dev
docker run --rm -i \
-e HOMEASSISTANT_URL=http://your-ha:8123 \
-e HOMEASSISTANT_TOKEN=your_token \
ghcr.io/homeassistant-ai/ha-mcp:dev
```
---
**Found an issue?** Please [open a new bug report](https://github.com/homeassistant-ai/ha-mcp/issues/new?template=bug_report.md) and mention this PR for context.
EOF
)"
- name: Comment on linked issues
if: steps.find-pr.outputs.skip != 'true' && steps.find-pr.outputs.issues
env:
GH_TOKEN: ${{ github.token }}
PR_NUM: ${{ steps.find-pr.outputs.pr_number }}
run: |
IFS=',' read -ra ISSUE_ARRAY <<< "${{ steps.find-pr.outputs.issues }}"
for ISSUE_NUM in "${ISSUE_ARRAY[@]}"; do
if [ -n "$ISSUE_NUM" ]; then
echo "Commenting on issue #$ISSUE_NUM"
gh issue comment $ISSUE_NUM --body "$(cat <<EOF
## ✅ This issue has been addressed in the dev channel!
A fix for this issue has been merged to master (PR #${PR_NUM}) and is available for testing in the **dev channel**.
**Test the fix before the Tuesday release:**
📖 **[Dev Channel Documentation](https://github.com/homeassistant-ai/ha-mcp/blob/master/docs/dev-channel.md)**
### Quick start
\`\`\`bash
# Run dev version
uvx ha-mcp-dev
# Check version
uvx ha-mcp-dev --version
\`\`\`
**Docker:**
\`\`\`bash
docker pull ghcr.io/homeassistant-ai/ha-mcp:dev
docker run --rm -i \\
-e HOMEASSISTANT_URL=http://your-ha:8123 \\
-e HOMEASSISTANT_TOKEN=your_token \\
ghcr.io/homeassistant-ai/ha-mcp:dev
\`\`\`
---
**After testing:**
- ✅ **If it's fixed:** Great! Feel free to comment here to confirm
- ❌ **If still broken:** [Open a new issue](https://github.com/homeassistant-ai/ha-mcp/issues/new?template=bug_report.md) and reference #${ISSUE_NUM}
- Closed issues can't be reopened by reporters
- A new issue helps us track the problem properly
EOF
)"
fi
done