chore: bump the actions group with 2 updates #157
Workflow file for this run
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: Build Preview | |
| on: | |
| pull_request: | |
| types: | |
| - labeled | |
| - synchronize | |
| permissions: | |
| contents: read | |
| issues: write | |
| pull-requests: write | |
| jobs: | |
| build-preview: | |
| if: > | |
| github.repository == 'mattrossman/forecaswatch2' && | |
| ( | |
| (github.event.action == 'labeled' && github.event.label.name == 'build-preview') || | |
| (github.event.action == 'synchronize' && contains(github.event.pull_request.labels.*.name, 'build-preview')) | |
| ) && | |
| github.event.pull_request.head.repo.full_name == github.repository | |
| runs-on: ubuntu-24.04 | |
| concurrency: | |
| group: build-preview-${{ github.event.pull_request.number }} | |
| cancel-in-progress: true | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 | |
| - name: Set up mise toolchain | |
| uses: jdx/mise-action@dba19683ed58901619b14f395a24841710cb4925 # v4.1.0 | |
| with: | |
| install: true | |
| cache: true | |
| - name: Install Pebble SDK | |
| run: scripts/ensure-pebble-sdk.sh | |
| - name: Build dev .pbw | |
| env: | |
| TELEMETRY_ENDPOINT: ${{ secrets.TELEMETRY_ENDPOINT_PREVIEW }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| mkdir -p build | |
| mise build dev 2>&1 | tee build/build-preview.log | |
| - name: Verify artifact exists | |
| run: test -f build/forecaswatch2-dev.pbw | |
| - name: Upload .pbw artifact | |
| id: upload | |
| uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 | |
| with: | |
| name: forecaswatch2-dev-pbw-pr-${{ github.event.pull_request.number }}.zip | |
| path: build/forecaswatch2-dev.pbw | |
| if-no-files-found: error | |
| retention-days: 14 | |
| - name: Upsert PR comment with artifact link | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| env: | |
| ARTIFACT_URL: ${{ steps.upload.outputs.artifact-url }} | |
| MEMORY_LOG_PATH: ${{ github.workspace }}/build/build-preview.log | |
| with: | |
| script: | | |
| const fs = require('node:fs'); | |
| const { parsePebbleMemoryReport, renderPebbleMemoryReport } = require(`${process.env.GITHUB_WORKSPACE}/scripts/parse-pebble-memory-report`); | |
| const marker = '<!-- build-preview-artifact -->'; | |
| const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/'); | |
| if (!process.env.ARTIFACT_URL) { | |
| throw new Error('upload-artifact did not return artifact-url'); | |
| } | |
| const runUrl = `${process.env.GITHUB_SERVER_URL}/${owner}/${repo}/actions/runs/${process.env.GITHUB_RUN_ID}`; | |
| const prNumber = context.payload.pull_request.number; | |
| const artifactName = `forecaswatch2-dev-pbw-pr-${prNumber}.zip`; | |
| const memoryLogPath = process.env.MEMORY_LOG_PATH; | |
| const memoryReport = memoryLogPath && fs.existsSync(memoryLogPath) | |
| ? renderPebbleMemoryReport(parsePebbleMemoryReport(fs.readFileSync(memoryLogPath, 'utf8'))) | |
| : '_No memory usage log was captured for this run._'; | |
| const body = [ | |
| marker, | |
| '✅ Preview dev build available.', | |
| '', | |
| `Download [${artifactName}](${process.env.ARTIFACT_URL})`, | |
| '', | |
| memoryReport, | |
| '', | |
| 'Artifacts are attached to the workflow run/job and require GitHub access to this repository.', | |
| `Run: [#${process.env.GITHUB_RUN_NUMBER}](${runUrl})`, | |
| ].join('\n'); | |
| const comments = await github.paginate(github.rest.issues.listComments, { | |
| owner, | |
| repo, | |
| issue_number: prNumber, | |
| per_page: 100, | |
| }); | |
| const existing = comments.find((comment) => | |
| comment.user?.type === 'Bot' && comment.body?.includes(marker) | |
| ); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ | |
| owner, | |
| repo, | |
| comment_id: existing.id, | |
| body, | |
| }); | |
| } else { | |
| await github.rest.issues.createComment({ | |
| owner, | |
| repo, | |
| issue_number: prNumber, | |
| body, | |
| }); | |
| } |