This repository was archived by the owner on Apr 7, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
π€ Deploy Bot Automation System #4
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
4c2ddd5
π€ ci: Deploy bot automation workflows
96b3279
Merge branch 'main' into bot/deploy-automation-1766526761
blackboxprogramming 270d218
Update .github/workflows/bot-docs-update.yml
blackboxprogramming e958904
Update .github/workflows/bot-docs-update.yml
blackboxprogramming fb7d0e8
Update .github/workflows/bot-pr-review.yml
blackboxprogramming 76ce0e1
Update .github/workflows/bot-release.yml
blackboxprogramming 04fb539
Update .github/workflows/bot-sync.yml
blackboxprogramming 486be47
Update .github/workflows/bot-pr-review.yml
blackboxprogramming 3fe684b
Update .github/workflows/bot-docs-update.yml
blackboxprogramming 81929a5
Update .github/workflows/bot-security-scan.yml
blackboxprogramming File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| name: Bot - Documentation Update | ||
|
|
||
| on: | ||
| push: | ||
| branches: [main, master] | ||
| paths: | ||
| - 'src/**' | ||
| - 'lib/**' | ||
| - '*.md' | ||
| schedule: | ||
| - cron: '0 0 * * 1' # Weekly on Monday | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| jobs: | ||
| update-docs: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Check README exists | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
|
|
||
| if (!fs.existsSync('README.md')) { | ||
| const template = `# ${context.repo.repo} | ||
|
|
||
| ## Overview | ||
| [Add project description] | ||
|
|
||
| ## Installation | ||
| \`\`\`bash | ||
| npm install | ||
| \`\`\` | ||
|
|
||
| ## Usage | ||
| [Add usage instructions] | ||
|
|
||
| ## Contributing | ||
| See CONTRIBUTING.md | ||
|
|
||
| ## License | ||
| [Add license] | ||
|
|
||
| --- | ||
| π€ Generated by BlackRoad Bot System | ||
| `; | ||
|
|
||
| fs.writeFileSync('README.md', template); | ||
|
|
||
| await github.request('PUT /repos/{owner}/{repo}/contents/{path}', { | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| path: 'README.md', | ||
| message: 'π€ docs: Add README template', | ||
| content: Buffer.from(template, 'utf8').toString('base64') | ||
| }); | ||
| } | ||
|
|
||
| - name: Generate API docs | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| // Simple JSDoc extraction | ||
| function extractDocs(filePath) { | ||
| const content = fs.readFileSync(filePath, 'utf8'); | ||
| const docRegex = /\/\*\*([\s\S]*?)\*\/\s*(?:export\s+)?(?:async\s+)?function\s+(\w+)/g; | ||
| const docs = []; | ||
|
|
||
| let match; | ||
| while ((match = docRegex.exec(content)) !== null) { | ||
| docs.push({ | ||
| name: match[2], | ||
| doc: match[1].trim() | ||
| }); | ||
| } | ||
|
|
||
| return docs; | ||
| } | ||
|
|
||
| function scanForFunctions(dir) { | ||
| const docs = []; | ||
| const entries = fs.readdirSync(dir, { withFileTypes: true }); | ||
|
|
||
| for (const entry of entries) { | ||
| const fullPath = path.join(dir, entry.name); | ||
|
|
||
| if (entry.name.startsWith('.') || entry.name === 'node_modules') { | ||
| continue; | ||
| } | ||
|
|
||
| if (entry.isDirectory()) { | ||
| docs.push(...scanForFunctions(fullPath)); | ||
| } else if (entry.name.endsWith('.js') || entry.name.endsWith('.ts')) { | ||
| docs.push(...extractDocs(fullPath)); | ||
| } | ||
| } | ||
|
|
||
| return docs; | ||
| } | ||
|
|
||
| if (fs.existsSync('src')) { | ||
| const docs = scanForFunctions('src'); | ||
|
|
||
| if (docs.length > 0) { | ||
| let apiDoc = '# API Documentation\n\n'; | ||
| apiDoc += '> Auto-generated from source code\n\n'; | ||
|
|
||
| for (const doc of docs) { | ||
| apiDoc += `## ${doc.name}\n\n`; | ||
| const cleanedDoc = doc.doc | ||
| .split('\n') | ||
| .map(line => line.replace(/^\s*\*\s?/, '')) | ||
| .join('\n'); | ||
| apiDoc += cleanedDoc + '\n\n'; | ||
| } | ||
|
|
||
| apiDoc += '\n---\nπ€ Generated by BlackRoad Bot System\n'; | ||
|
|
||
| fs.writeFileSync('API.md', apiDoc); | ||
|
|
||
| console.log(`Generated API documentation with ${docs.length} functions`); | ||
| } | ||
| } | ||
|
|
||
| - name: Update documentation links | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
|
|
||
| if (fs.existsSync('README.md')) { | ||
| let readme = fs.readFileSync('README.md', 'utf8'); | ||
|
|
||
| // Add links section if missing | ||
| if (!readme.includes('## Links') && !readme.includes('## Resources')) { | ||
| const links = ` | ||
|
|
||
| ## Links | ||
|
|
||
| - [Documentation](https://docs.blackroad.io) | ||
| - [API Reference](./API.md) | ||
| - [Contributing](./CONTRIBUTING.md) | ||
| - [BlackRoad OS](https://github.com/BlackRoad-OS) | ||
| `; | ||
| readme += links; | ||
| fs.writeFileSync('README.md', readme); | ||
| } | ||
| } | ||
|
|
||
| - name: Create PR for doc updates | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const fs = require('fs'); | ||
|
|
||
| // Check if we made changes | ||
| const { execSync } = require('child_process'); | ||
| const status = execSync('git status --porcelain').toString(); | ||
|
|
||
| if (status.trim()) { | ||
| const branchName = `bot/docs-update-${Date.now()}`; | ||
|
|
||
| execSync(`git config user.name "github-actions[bot]"`); | ||
| execSync(`git config user.email "41898282+github-actions[bot]@users.noreply.github.com"`); | ||
| execSync(`git checkout -b ${branchName}`); | ||
| execSync(`git add .`); | ||
| execSync(`git commit -m "π€ docs: Auto-update documentation"`); | ||
| execSync(`git push origin ${branchName}`); | ||
|
|
||
| await github.rest.pulls.create({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| title: 'π€ docs: Auto-update documentation', | ||
| body: `## Documentation Updates | ||
|
|
||
| This PR includes automated documentation updates: | ||
| - README improvements | ||
| - API documentation generation | ||
| - Link updates | ||
|
|
||
| **Generated by:** BlackRoad Bot System | ||
| **Review:** Please verify changes before merging | ||
|
|
||
| cc: @${context.repo.owner}`, | ||
| head: branchName, | ||
| base: 'main' | ||
| }); | ||
| } | ||
|
|
||
| - name: Log to memory | ||
| run: | | ||
| if [ -f ~/memory-system.sh ]; then | ||
| ~/memory-system.sh log bot-action "docs-update" "Documentation updated for ${{ github.repository }}" | ||
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,122 @@ | ||
| name: Bot - Issue Triage | ||
|
|
||
| on: | ||
| issues: | ||
| types: [opened, edited, reopened] | ||
|
|
||
| permissions: | ||
| issues: write | ||
| contents: read | ||
|
|
||
| jobs: | ||
| triage: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Auto-label issue | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const issue = context.payload.issue; | ||
| const title = issue.title.toLowerCase(); | ||
| const body = issue.body ? issue.body.toLowerCase() : ''; | ||
| const labels = []; | ||
|
|
||
| // Auto-detect issue type | ||
| if (title.includes('bug') || body.includes('error') || body.includes('broken')) { | ||
| labels.push('bug'); | ||
| } | ||
| if (title.includes('feature') || title.includes('enhancement')) { | ||
| labels.push('enhancement'); | ||
| } | ||
| if (title.includes('docs') || title.includes('documentation')) { | ||
| labels.push('documentation'); | ||
| } | ||
| if (title.includes('security') || body.includes('vulnerability')) { | ||
| labels.push('security'); | ||
| } | ||
| if (title.includes('performance') || body.includes('slow')) { | ||
| labels.push('performance'); | ||
| } | ||
| if (title.includes('test')) { | ||
| labels.push('testing'); | ||
| } | ||
|
|
||
| // Priority detection | ||
| if (title.includes('urgent') || title.includes('critical') || body.includes('production down')) { | ||
| labels.push('priority:high'); | ||
| } else if (title.includes('minor') || title.includes('trivial')) { | ||
| labels.push('priority:low'); | ||
| } else { | ||
| labels.push('priority:medium'); | ||
| } | ||
|
|
||
| // Add labels | ||
| if (labels.length > 0) { | ||
| await github.rest.issues.addLabels({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issue.number, | ||
| labels: labels | ||
| }); | ||
| } | ||
|
|
||
| // Add triage comment | ||
| const comment = `π Thanks for opening this issue! | ||
|
|
||
| π€ **Bot Triage:** | ||
| - Auto-labeled as: ${labels.join(', ')} | ||
| - Assigned priority based on content | ||
| - A team member will review soon | ||
|
|
||
| This is an automated message from the BlackRoad bot system.`; | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issue.number, | ||
| body: comment | ||
| }); | ||
|
|
||
| - name: Check for duplicates | ||
| uses: actions/github-script@v7 | ||
| with: | ||
| script: | | ||
| const issue = context.payload.issue; | ||
| const title = issue.title.toLowerCase(); | ||
|
|
||
| // Search for similar issues | ||
| const { data: issues } = await github.rest.issues.listForRepo({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| state: 'all', | ||
| per_page: 100 | ||
| }); | ||
|
|
||
| const similar = issues.filter(i => | ||
| i.number !== issue.number && | ||
| i.title.toLowerCase().includes(title.split(' ')[0]) | ||
| ); | ||
|
|
||
| if (similar.length > 0) { | ||
| const duplicateList = similar.slice(0, 5).map(i => `- #${i.number}: ${i.title}`).join('\n'); | ||
|
|
||
| await github.rest.issues.createComment({ | ||
| owner: context.repo.owner, | ||
| repo: context.repo.repo, | ||
| issue_number: issue.number, | ||
| body: `π€ **Possible Duplicates Detected:** | ||
|
|
||
| ${duplicateList} | ||
|
|
||
| Please check if any of these issues match your report.` | ||
| }); | ||
| } | ||
|
|
||
| - name: Log to memory | ||
| run: | | ||
| if [ -f ~/memory-system.sh ]; then | ||
| ~/memory-system.sh log bot-action "issue-triage" "Triaged issue #${{ github.event.issue.number }} in ${{ github.repository }}" | ||
| fi | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The duplicate detection logic only checks if the first word of the title appears in other issue titles. This is overly simplistic and will produce many false positives. For example, issues starting with "Add", "Fix", or "Update" would all be flagged as potential duplicates of each other. Consider using a more sophisticated similarity algorithm or checking for more significant overlap between titles.