-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathweekly-version-check-action.yml
More file actions
309 lines (248 loc) Β· 13.1 KB
/
weekly-version-check-action.yml
File metadata and controls
309 lines (248 loc) Β· 13.1 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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
name: Check ioBroker Copilot Template Version
# DEPRECATION NOTICE: This template has been replaced by the centralized version
# Please use: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/templates/centralized-version-check-action.yml
#
# The centralized version provides:
# - Dynamic version checking using metadata.json
# - Better repository status detection
# - Copilot-driven automation instead of manual scripts
# - Enhanced issue creation and duplicate prevention
#
# Migration: Replace the contents of your .github/workflows/check-copilot-template.yml
# with the centralized template for improved functionality.
on:
schedule:
- cron: '0 0 * * 0' # Weekly check every Sunday at midnight UTC
workflow_dispatch: # Allow manual triggering
jobs:
check-template:
runs-on: ubuntu-latest
permissions:
issues: write
contents: read
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Migration Notice
run: |
echo "β οΈ DEPRECATION NOTICE: This workflow template is deprecated"
echo "π Please migrate to the centralized version for enhanced features:"
echo " https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/templates/centralized-version-check-action.yml"
echo ""
echo "π― Enhanced features in centralized version:"
echo " - Dynamic version detection using metadata.json"
echo " - Better repository status detection"
echo " - Copilot-driven automation (no manual scripts)"
echo " - Enhanced issue creation with duplicate prevention"
echo ""
echo "π Migration steps:"
echo " 1. Replace your .github/workflows/check-copilot-template.yml content"
echo " 2. Copy from the centralized template URL above"
echo " 3. Commit the updated workflow"
echo ""
echo "β‘ Continuing with legacy version for compatibility..."
- name: Check template version
id: version-check
run: |
echo "π Checking ioBroker Copilot template version..."
# Get current version from local template
if [ -f ".github/copilot-instructions.md" ]; then
CURRENT_VERSION=$(grep "Version:" .github/copilot-instructions.md | head -1 | sed 's/.*Version:\s*//' | tr -d '*' | xargs)
echo "π Current version: $CURRENT_VERSION"
else
CURRENT_VERSION="none"
echo "β No copilot-instructions.md file found"
fi
# Get latest version from remote
echo "π Fetching latest template version..."
LATEST_VERSION=$(curl -s https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md | grep "Version:" | head -1 | sed 's/.*Version:\s*//' | tr -d '*' | xargs)
echo "π Latest version: $LATEST_VERSION"
# Set outputs
echo "current-version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "latest-version=$LATEST_VERSION" >> $GITHUB_OUTPUT
if [ "$CURRENT_VERSION" != "$LATEST_VERSION" ] || [ "$CURRENT_VERSION" = "none" ]; then
echo "π Update needed!"
echo "update-needed=true" >> $GITHUB_OUTPUT
else
echo "β
Template is up-to-date"
echo "update-needed=false" >> $GITHUB_OUTPUT
fi
- name: Check for existing template-related issues
id: check-issue
if: steps.version-check.outputs.update-needed == 'true'
uses: actions/github-script@v7
with:
script: |
console.log('π Checking for existing template update issues...');
const { data: issues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
per_page: 100
});
// Look for any existing template-related issues
const templateIssues = issues.filter(issue => {
const title = issue.title.toLowerCase();
const hasLabels = issue.labels.some(label =>
label.name === 'template-update' ||
label.name === 'automation' ||
label.name === 'copilot-setup'
);
const hasKeywords = title.includes('copilot') && (
title.includes('template') ||
title.includes('setup') ||
title.includes('update')
);
return hasLabels || hasKeywords;
});
if (templateIssues.length > 0) {
console.log(`π Found ${templateIssues.length} existing template-related issue(s):`);
templateIssues.forEach(issue => {
console.log(` - #${issue.number}: ${issue.title}`);
});
return templateIssues[0].number;
} else {
console.log('β
No existing template-related issues found');
return null;
}
- name: Create or update template issue
if: steps.version-check.outputs.update-needed == 'true' && !steps.check-issue.outputs.result
uses: actions/github-script@v7
with:
script: |
const currentVersion = '${{ steps.version-check.outputs.current-version }}';
const latestVersion = '${{ steps.version-check.outputs.latest-version }}';
const repoName = context.repo.repo;
console.log(`π― Creating template issue for ${context.repo.owner}/${repoName}`);
console.log(`π Current: ${currentVersion}, Latest: ${latestVersion}`);
let title, body, labels;
if (currentVersion === 'none') {
title = 'π€ Setup ioBroker GitHub Copilot Instructions';
labels = ['copilot-setup', 'automation', 'enhancement'];
body = `# π€ Automated ioBroker Copilot Instructions Setup
**Automated Detection**: This ioBroker adapter repository doesn't have GitHub Copilot instructions configured yet.
**Latest Available Version**: ${latestVersion}
## π― What This Sets Up
GitHub Copilot instructions will enhance your development experience by providing:
- β¨ ioBroker-specific code suggestions
- π‘οΈ Best practices for adapter development
- π§ͺ Enhanced testing patterns with @iobroker/testing
- π Improved README and documentation generation
- π§ Smart error handling and state management
## π Automated Setup Process
**GitHub Copilot**: Please help me set up GitHub Copilot instructions for my ioBroker adapter repository.
### Primary Task
Create a complete \`.github/copilot-instructions.md\` file using this process:
1. **Download and integrate the latest template**:
\`\`\`
Fetch the ioBroker Copilot template from:
https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md
Create .github/copilot-instructions.md by:
- Removing the template comment block (<!-- to --> section)
- Setting version to ${latestVersion}
- Adding Template Source reference
- Customizing [CUSTOMIZE] sections for this ${repoName} adapter
\`\`\`
2. **Adapter-Specific Customization**:
\`\`\`
In the [CUSTOMIZE] Project-Specific Instructions section, please add:
- This ${repoName} adapter's specific API patterns and authentication
- Unique error codes and handling specific to this service
- Custom device discovery or connection patterns
- Any special configuration requirements for this adapter
\`\`\`
## π§ Validation Checklist
After setup, please confirm:
- [ ] File created at \`.github/copilot-instructions.md\`
- [ ] Version set to \`${latestVersion}\`
- [ ] Template source reference included
- [ ] [CUSTOMIZE] sections populated with ${repoName}-specific patterns
- [ ] Enhanced Copilot suggestions working (test with \`this.setState(\` in a .js file)
## π Next Steps
Once setup is complete:
1. **Weekly Monitoring**: This action will automatically check for template updates
2. **Preserved Customizations**: All your [CUSTOMIZE] sections will be preserved in future updates
3. **Enhanced Development**: Start coding and experience improved ioBroker-specific suggestions
## π Reference
- **Template Repository**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions
- **Full Setup Guide**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions/blob/main/docs/setup.md
---
*π€ This issue was automatically created by GitHub Actions. The weekly monitoring will continue to check for template updates while preserving all your customizations.*`;
} else {
title = 'π€ Update ioBroker Copilot Instructions Template';
labels = ['template-update', 'automation', 'enhancement'];
body = `# π€ ioBroker Copilot Template Update Available
**Automated Detection**: Your ioBroker Copilot instructions template has an update available.
- **Current Version**: \`${currentVersion}\`
- **Latest Version**: \`${latestVersion}\`
- **Repository**: ${context.repo.owner}/${repoName}
## π Automated Update Process
**GitHub Copilot**: Please help me update my ioBroker Copilot template while preserving all customizations.
### Template Update Task
Use this exact merge prompt:
\`\`\`
"Update my .github/copilot-instructions.md by merging the latest ioBroker template from:
https://github.com/DrozmotiX/ioBroker-Copilot-Instructions/blob/main/template.md
CRITICAL PRESERVATION REQUIREMENTS:
1. Keep ALL [CUSTOMIZE] sections and their content exactly as they are
2. Preserve any ${repoName}-specific context not covered by the standard template
3. Maintain custom error handling, API patterns, or authentication flows
4. Keep any unique testing scenarios or configuration instructions
5. REMOVE any duplicate content from [CUSTOMIZE] sections that already exists in the standard template
6. Keep only truly unique, adapter-specific content in [CUSTOMIZE] sections
UPDATE REQUIREMENTS:
1. Integrate latest ioBroker best practices from the new template
2. Update version number to ${latestVersion}
3. Refresh Template Source reference
4. Add any new standard sections that are missing
5. Clean up [CUSTOMIZE] sections to avoid duplicating standard template content
Show me a summary of what will be changed before applying the update."
\`\`\`
## π What's New in ${latestVersion}
Recent template improvements typically include:
- π§ͺ Enhanced testing patterns and best practices
- π‘οΈ Improved error handling recommendations
- π Better documentation generation patterns
- π§ Updated dependency management guidance
- β‘ Performance optimization suggestions
## π§ Validation Checklist
After the update, please confirm:
- [ ] All [CUSTOMIZE] sections preserved exactly as they were
- [ ] Version updated to \`${latestVersion}\`
- [ ] Custom ${repoName}-specific content intact
- [ ] New best practices integrated without conflicts
- [ ] Template source reference updated
- [ ] Enhanced suggestions still working (test in your code editor)
- [ ] No duplicate content between [CUSTOMIZE] sections and standard template
## π‘οΈ Safety Features
This automated update process:
- β
**Preserves Customizations**: All [CUSTOMIZE] sections are automatically maintained
- π **No Data Loss**: Your adapter-specific patterns and configurations remain intact
- π **Audit Trail**: All changes are tracked in this issue for review
- π **Reversible**: You can always revert changes if needed
## π Reference
- **Template Repository**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions
- **Template Source**: https://raw.githubusercontent.com/DrozmotiX/ioBroker-Copilot-Instructions/main/template.md
- **Update Guide**: https://github.com/DrozmotiX/ioBroker-Copilot-Instructions/blob/main/docs/automated-updates.md
---
*π€ This issue was automatically created by GitHub Actions on ${new Date().toISOString().split('T')[0]}. Weekly monitoring will continue to check for updates while preserving your customizations.*`;
}
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: labels
});
console.log(`β
Created issue #${issue.data.number}: ${title}`);
return issue.data.number;
- name: Log completion
if: steps.version-check.outputs.update-needed == 'false'
run: |
echo "β
Template check completed - no updates needed"
echo "π Current version ${{ steps.version-check.outputs.current-version }} is up-to-date"
- name: Log issue creation
if: steps.version-check.outputs.update-needed == 'true' && steps.check-issue.outputs.result
run: |
echo "βΉοΈ Template update needed, but found existing issue #${{ steps.check-issue.outputs.result }}"
echo "π Current: ${{ steps.version-check.outputs.current-version }}, Latest: ${{ steps.version-check.outputs.latest-version }}"