Update preview.yaml #14
This file contains 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 and Preview | |
on: | |
push: | |
branches: | |
- master | |
pull_request: | |
workflow_dispatch: | |
permissions: | |
contents: read | |
pull-requests: write | |
checks: write | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
timeout-minutes: 1 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- run: bun install --frozen-lockfile | |
- run: timeout 12s bun pre-commit | |
- run: bun run test | |
- run: ./check-lines.sh | |
- name: Bundle size breakdown | |
run: | | |
bun run build --sourcemap true | |
node src/ci/dependency_report.cjs dist/ | column -t -s ":" | |
- run: ./check-bundle-size.sh | |
- name: Build for Lighthouse | |
run: bun run build | |
- name: Run Lighthouse CI | |
uses: treosh/lighthouse-ci-action@v11 | |
id: lighthouse | |
with: | |
configPath: './lighthouserc.json' | |
uploadArtifacts: true | |
temporaryPublicStorage: true | |
- name: Upload Lighthouse reports | |
uses: actions/upload-artifact@v4 | |
with: | |
name: lighthouse-reports | |
path: ${{ steps.lighthouse.outputs.resultsPath }} | |
- name: Check Lighthouse CI status | |
if: steps.lighthouse.outputs.assertionResults != '[]' | |
run: | | |
echo "Lighthouse CI assertions failed. Check the report for details." | |
exit 1 | |
build: | |
runs-on: ubuntu-latest | |
timeout-minutes: 1 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- run: bun install --frozen-lockfile | |
- run: bun run build | |
- name: Upload built project | |
uses: actions/upload-artifact@v4 | |
with: | |
path: ./dist | |
overwrite: true | |
retention-days: 1 | |
name: build-artifacts-${{ github.run_id }} | |
preview: | |
needs: build | |
runs-on: ubuntu-latest | |
timeout-minutes: 1 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: oven-sh/setup-bun@v1 | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: build-artifacts-${{ github.run_id }} | |
path: ./dist | |
- name: Deploy to Cloudflare Pages | |
uses: cloudflare/wrangler-action@v3 | |
with: | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
apiToken: ${{ secrets.CLOUDFLARE_PAGES_TOKEN }} | |
command: pages deploy dist --project-name=connect --branch=${{ github.ref_name }} --commit-dirty=true | |
- name: Checkout ci-artifacts | |
uses: actions/checkout@v4 | |
with: | |
repository: commaai/ci-artifacts | |
ssh-key: ${{ secrets.CI_ARTIFACTS_DEPLOY_KEY }} | |
path: ${{ github.workspace }}/ci-artifacts | |
ref: master | |
- name: Take screenshots | |
run: node src/ci/screenshots.cjs https://${{ github.ref_name }}.connect-d5y.pages.dev ${{ github.workspace }}/ci-artifacts | |
- name: Push Screenshots | |
working-directory: ${{ github.workspace }}/ci-artifacts | |
run: | | |
git checkout -b new-connect/${{ github.ref_name }} | |
git config user.name "GitHub Actions Bot" | |
git config user.email "<>" | |
git add . | |
git commit -m "screenshots for ${{ github.ref_name }}" | |
git push origin new-connect/${{ github.ref_name }} --force | |
- name: Comment URL (PR only) | |
if: github.event_name == 'pull_request' | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Deployed preview: https://${{ github.ref_name }}.connect-d5y.pages.dev` | |
}) |