lighthouse-action
lighthouse-action copied to clipboard
Wait to audit until successful status from deploy steps
Thanks for a cool GitHub Action! I was wondering if it was possible to run this after a delay?
Here is the use case I am after...
- Merge code into master
- CircleCI workflow runs and deploys the code to foo.com (which the GH Action doesn't "know" about)
- Run lighthouse-action after 10 minutes against foo.com (10 minutes is arbitrary, basically I just want to wait until the code is live)
Any thoughts would be great! Feel free to close though if out of the scope of this project.
Thanks for the kind words!
I ran into the same problem and ended up using this band-aid fix for now:
# deploy steps here
- name: Sleep for 30 seconds
run: sleep 30
# lighthouse step here
...which you could change to sleep 10m
for 10 minutes or whatever's appropriate — I should probably add this to the readme since this is likely race condition is likely present in most use cases. But I'd like to do this the right way and actually get the job status from CircleCI or Netlify or whatever service and start the audit on successful deploy. Adding to the to-do list!
Apologies for the late reply, thanks for your patience! :)
I have an idea here. How about you look at the contents of the repository, and compare everything to the online version? You repeatedly do that until the online version matches the repository.
I ended up using the repository_dispatch event trigger. After CircleCI deploys, I make a curl POST to the GitHub API and then the Lighthouse action is listening for the repository_dispatch event and runs when that POST happens.
https://help.github.com/en/articles/events-that-trigger-workflows#external-events-repository_dispatch
Good idea! I'm using GitHub pages though.
I've not used it yet, but it looks promising.
https://github.com/maddox/actions/tree/master/wait-for-200
Here's the approach we took with this action. Worked out really well, since Netlify actions are part of our checks for a PR.
It waits for all checks except the ones we specify (ignoreActions
), which means it waits for the deploy preview + header rules + etc from Netlify. Polls every 20 seconds, and that interval is configurable. Then, it just runs this action like normal.
Of note: make sure to include this job's name in the ignoreActions
, otherwise it'll wait on itself. It'd be really cool to make this part of the base action.
steps:
- name: 'Wait for deploy preview to finish'
uses: 'WyriHaximus/github-action-wait-for-status@master'
with:
# We care only about the Netlify checks finishing
ignoreActions: 'lighthouse audit,triage,notify,tests'
checkInterval: 20
env:
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
- name: Audit Netlify deploy preview
uses: jakejarvis/lighthouse-action@master
with:
# This is the deploy preview base URL (where PRs show for deploy previews)
netlify_site: ${{ env[github.base_ref] }}.netlify.com
- uses: actions/upload-artifact@master
with:
name:
Lighthouse report (${{github.base_ref}} ${{ github.sha }})
path: './report'