Skip to content

Commit

Permalink
ci: lighthouse script (#1054)
Browse files Browse the repository at this point in the history
* ci: lighthouse (WIP)

* ci: lighthouse (WIP)

* ci: lighthouse (WIP)

* ci: lighthouse

* ci: set up permissions

* ci: lighthouse

* ci: lighthouse fix urls

* ci: lighthouse - wait for deployment to finish
  • Loading branch information
jy95 authored Nov 30, 2024
1 parent 1fabefe commit c2d3d81
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/lighthouse.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Lighthouse Compare Action
on:
pull_request:

jobs:
getPreviewUrl:
runs-on: ubuntu-latest
outputs:
preview_url: ${{ steps.add_prefix.outputs.full_url }}
steps:
- uses: actions/checkout@v4
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#masking-a-value-in-a-log
# https://kinsta.com/blog/github-actions-secret/
- name: Add Mask on vercel token
run: echo "::add-mask::${{ secrets.VERCEL_TOKEN }}"
- name: Get Vercel Preview URL
id: vercel_preview_url
uses: zentered/[email protected]
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
with:
vercel_project_id: ${{ secrets.VERCEL_PROJECT_ID }}
- name: Await for Vercel deployment
uses: UnlyEd/[email protected]
id: await-vercel
env:
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
with:
deployment-url: ${{ steps.vercel_preview_url.outputs.preview_url }}
timeout: 300
poll-interval: 5
- name: Combine Prefix "https://"
id: add_prefix
run: echo "full_url=https://${{ steps.vercel_preview_url.outputs.preview_url }}" >> $GITHUB_OUTPUT
- name: Print URL
run: echo "${{ steps.add_prefix.outputs.full_url }}"

lighthouse:
needs: getPreviewUrl
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
pull-requests: write
issues: write
env:
# Subpaths to investigate
SUBPATHS: "/games,/games/series,/games/dlcs,/planning,/backlog,/tests,/stats,/links"
steps:
- uses: actions/checkout@v4
- run: mkdir -p ${{ github.workspace }}/tmp/artifacts
- name: Construct URLs
id: construct_urls
run: |
URL_LIST=$(echo "${{ env.SUBPATHS }}" | tr ',' '\n' | sed "s|^|${{ needs.getPreviewUrl.outputs.preview_url }}|g" | tr '\n' ',' | sed 's|,$||')
echo "url_list=$URL_LIST" >> $GITHUB_OUTPUT
- name: Debug URLs
run: |
echo "Constructed URLs: ${{ steps.construct_urls.outputs.url_list }}"
- uses: foo-software/lighthouse-check-action@master
with:
urls: ${{ steps.construct_urls.outputs.url_list }}
device: all
prCommentEnabled: true
gitHubAccessToken: ${{ secrets.GITHUB_TOKEN }}
outputDirectory: ${{ github.workspace }}/tmp/artifacts
- name: Upload artifacts
uses: actions/[email protected]
with:
name: Lighthouse reports
path: ${{ github.workspace }}/tmp/artifacts
retention-days: 1

0 comments on commit c2d3d81

Please sign in to comment.