Upstream Auto-Triage & Redirect #16
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
| name: "Upstream Auto-Triage & Redirect" | |
| on: | |
| schedule: | |
| - cron: '30 */4 * * *' | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: "Dry run (no comments posted)" | |
| type: boolean | |
| default: false | |
| scan_forks: | |
| description: "Also scan fork issues/PRs" | |
| type: boolean | |
| default: false | |
| concurrency: | |
| group: upstream-triage | |
| cancel-in-progress: true | |
| env: | |
| NODE_VERSION: "22" | |
| jobs: | |
| stats: | |
| name: "App Stats" | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| outputs: | |
| version: ${{ steps.s.outputs.version }} | |
| drivers: ${{ steps.s.outputs.drivers }} | |
| fps: ${{ steps.s.outputs.fps }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - id: s | |
| run: | | |
| V=$(node -p "require('./app.json').version") | |
| D=$(ls -d drivers/*/ 2>/dev/null | wc -l) | |
| F=$(grep -rohE '"_T[A-Za-z0-9_]+"' drivers/*/driver.compose.json | sort -uf | wc -l) | |
| echo "version=$V" >> "$GITHUB_OUTPUT" | |
| echo "drivers=$D" >> "$GITHUB_OUTPUT" | |
| echo "fps=$F" >> "$GITHUB_OUTPUT" | |
| triage-upstream: | |
| name: "Triage JohanBendz" | |
| needs: stats | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Triage issues and PRs | |
| env: | |
| GH_TOKEN: ${{ secrets.TRIAGE_PAT || secrets.GITHUB_TOKEN }} | |
| GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} | |
| TARGET_REPO: JohanBendz/com.tuya.zigbee | |
| APP_VERSION: ${{ needs.stats.outputs.version }} | |
| DRIVER_COUNT: ${{ needs.stats.outputs.drivers }} | |
| FP_COUNT: ${{ needs.stats.outputs.fps }} | |
| DRY_RUN: ${{ inputs.dry_run || 'false' }} | |
| SCAN_FORKS: ${{ inputs.scan_forks || 'false' }} | |
| run: node .github/scripts/triage-upstream-enhanced.js | |
| - name: Create tracking issue for new FPs | |
| if: hashFiles('/tmp/upstream_new_fps.json') != '' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs=require('fs'); | |
| const data=JSON.parse(fs.readFileSync('/tmp/upstream_new_fps.json','utf8')); | |
| if(!data.length)return; | |
| const rows=data.slice(0,50).map(d=>`| \`${d.fp}\` | ${d.source} | ${d.type} |`).join('\n'); | |
| await github.rest.issues.create({ | |
| owner:context.repo.owner,repo:context.repo.repo, | |
| title:`[Auto] ${data.length} new fingerprint(s) from upstream`, | |
| body:`## New fingerprints from upstream triage\n\n| Fingerprint | Source | Type |\n|---|---|---|\n${rows}\n\nPlease add these to the appropriate driver.compose.json.`, | |
| labels:['enhancement','auto-triage'] | |
| }); | |
| triage-dlnraja: | |
| name: "Triage dlnraja" | |
| needs: stats | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 20 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - name: Triage issues and PRs | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }} | |
| TARGET_REPO: dlnraja/com.tuya.zigbee | |
| APP_VERSION: ${{ needs.stats.outputs.version }} | |
| DRIVER_COUNT: ${{ needs.stats.outputs.drivers }} | |
| FP_COUNT: ${{ needs.stats.outputs.fps }} | |
| DRY_RUN: ${{ inputs.dry_run || 'false' }} | |
| SCAN_FORKS: "false" | |
| run: node .github/scripts/triage-upstream-enhanced.js | |
| scan-forum: | |
| name: "Scan Forum" | |
| needs: stats | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 15 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| - uses: actions/cache@v4 | |
| with: | |
| path: /tmp/last_forum_post.txt | |
| key: forum-${{ github.run_number }} | |
| restore-keys: forum- | |
| - name: Scan forum for new device requests | |
| env: | |
| LAST_POST_FILE: /tmp/last_forum_post.txt | |
| run: node .github/scripts/scan-forum.js | |
| - name: Create issue for forum requests | |
| if: hashFiles('/tmp/forum_issues.json') != '' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs=require('fs'); | |
| const issues=JSON.parse(fs.readFileSync('/tmp/forum_issues.json','utf8')); | |
| if(!issues.length)return; | |
| const rows=issues.map(i=> | |
| `| ${i.user} | ${i.date} | [#${i.postNum}](https://community.homey.app/t/${i.topicId}/${i.postNum}) | \`${i.missing.join('`,`')}\` |`).join('\n'); | |
| await github.rest.issues.create({ | |
| owner:context.repo.owner,repo:context.repo.repo, | |
| title:`[Forum] ${issues.length} device request(s)`, | |
| body:`## Forum device requests\n\n| User | Date | Post | Missing FPs |\n|---|---|---|---|\n${rows}`, | |
| labels:['enhancement','forum-request'] | |
| }); | |
| summary: | |
| name: "Summary" | |
| needs: [triage-upstream, triage-dlnraja, scan-forum] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| steps: | |
| - run: | | |
| echo "## Upstream Auto-Triage Complete" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- JohanBendz: ${{ needs.triage-upstream.result }}" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- dlnraja: ${{ needs.triage-dlnraja.result }}" >> "$GITHUB_STEP_SUMMARY" | |
| echo "- Forum: ${{ needs.scan-forum.result }}" >> "$GITHUB_STEP_SUMMARY" |