Repository navigation
Remove version compatibility check entirely #612
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: Compile WebUI on MaslowBot Review Request | |
| on: | |
| pull_request: | |
| types: [review_requested] | |
| issue_comment: | |
| types: [created] | |
| jobs: | |
| compile-webui: | |
| runs-on: ubuntu-latest | |
| # Run when MaslowBot is requested as reviewer OR when specific build commands are used in a comment on a PR | |
| # Handles both single reviewer (requested_reviewer) and multiple reviewers (requested_reviewers) scenarios | |
| # Also handles issue_comment trigger for Copilot-created PRs | |
| if: | | |
| (github.event_name == 'pull_request' && ( | |
| github.event.requested_reviewer.login == 'MaslowBot' || | |
| contains(github.event.requested_reviewers.*.login, 'MaslowBot') | |
| )) || | |
| (github.event_name == 'issue_comment' && | |
| github.event.issue.pull_request != null && | |
| (contains(github.event.comment.body, 'please build') || contains(github.event.comment.body, '/build')) | |
| ) | |
| steps: | |
| - name: Get PR details for issue comment | |
| if: github.event_name == 'issue_comment' | |
| id: pr | |
| run: | | |
| PR_NUMBER=${{ github.event.issue.number }} | |
| PR_DATA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| "https://api.github.com/repos/${{ github.repository }}/pulls/${PR_NUMBER}") | |
| echo "head_sha=$(echo "$PR_DATA" | jq -r .head.sha)" >> $GITHUB_OUTPUT | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| # For issue_comment events, checkout the PR head commit instead of the default branch | |
| ref: ${{ github.event_name == 'issue_comment' && steps.pr.outputs.head_sha || github.sha }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Cache npm dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: node_modules | |
| key: ${{ runner.os }}-npm-${{ hashFiles('package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-npm- | |
| - name: Install npm dependencies | |
| run: npm install | |
| - name: Build WebUI | |
| run: gulp package --lang en | |
| - name: Create README for artifact | |
| run: | | |
| echo "ESP3D WebUI Update Package" > dist/README.txt | |
| echo "" >> dist/README.txt | |
| echo "Instructions:" >> dist/README.txt | |
| echo "1. Extract this zip file to a folder" >> dist/README.txt | |
| echo "2. Upload the index.html.gz file to your ESP3D device" >> dist/README.txt | |
| echo "3. The index.html.gz file contains the updated WebUI" >> dist/README.txt | |
| echo "" >> dist/README.txt | |
| echo "Note: Upload the index.html.gz file directly - do not extract it first." >> dist/README.txt | |
| - name: Upload WebUI as artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: Updated UI | |
| path: | | |
| dist/index.html.gz | |
| dist/README.txt | |
| retention-days: 30 | |
| - name: Comment on PR with WebUI info | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const fs = require('fs'); | |
| const path = 'dist/index.html.gz'; | |
| const stats = fs.statSync(path); | |
| const fileSizeInBytes = stats.size; | |
| const fileSizeInKB = (fileSizeInBytes / 1024).toFixed(2); | |
| // Determine the PR number and commit SHA based on the event type | |
| let prNumber, commitSha; | |
| if (context.eventName === 'pull_request') { | |
| prNumber = context.issue.number; | |
| commitSha = context.payload.pull_request.head.sha; | |
| } else if (context.eventName === 'issue_comment') { | |
| prNumber = context.issue.number; | |
| // Get the PR details to get the latest commit SHA | |
| const { data: pr } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: prNumber | |
| }); | |
| commitSha = pr.head.sha; | |
| } | |
| const triggerText = context.eventName === 'pull_request' | |
| ? '_This comment was automatically generated when @MaslowBot was requested as a reviewer._' | |
| : '_This comment was automatically generated in response to a build request comment._'; | |
| const comment = `🤖 **WebUI Compilation Complete** 🤖 | |
| ✅ Successfully compiled ESP3D WebUI for English language | |
| **Build Details:** | |
| - Commit: \`${commitSha}\` | |
| - Language: \`en\` (English) | |
| - WebUI size: ${fileSizeInKB} KB (compressed) | |
| - Build time: ~3 seconds | |
| **Download:** | |
| Download the "Updated UI.zip" file from the [Actions tab](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}). | |
| **Installation Instructions:** | |
| 1. Download and extract the "Updated UI.zip" file | |
| 2. Upload the index.html.gz file from the extracted folder to your ESP3D device | |
| 3. The README.txt file in the zip contains detailed instructions | |
| ${triggerText}`; | |
| github.rest.issues.createComment({ | |
| issue_number: prNumber, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); |