JakePartusch / wait-for-netlify-action

A GitHub action that will wait until a Netlify Preview deploy has completed before continuing on
MIT License
47 stars 52 forks source link

Fix Lighthouse example #10

Open lunelson opened 4 years ago

lunelson commented 4 years ago

The Lighthouse example in the README could be improved:

name: Lighthouse
on: pull_request
jobs:
  netlify-deploy-preview:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
        with:
          ref: ${{ github.event.pull_request.head.sha }}
      - name: Read .nvmrc version
        run: echo "##[set-output name=NVMRC;]$(cat .nvmrc)"
        id: nvm
      - name: Set Node.js version
        uses: actions/setup-node@v1
        with:
          node-version: "${{ steps.nvm.outputs.NVMRC }}"
      - name: Wait for Netlify Preview
        uses: jakepartusch/wait-for-netlify-action@v1.2
        id: netlify
        with:
          site_name: 'your-netlify-site-name'
          max_timeout: 300
      - name: Lighthouse CI
        run: |
          npm install -g @lhci/cli
          lhci autorun --upload.target=temporary-public-storage --collect.url=${{ steps.netlify.outputs.url }} || echo "LHCI failed!"
        env:
          LHCI_GITHUB_APP_TOKEN: ${{ secrets.LHCI_GITHUB_APP_TOKEN }}
JakePartusch commented 4 years ago

Thanks for the feedback @lunelson ! I definitely agree about the install steps.

I'm sort of confused about this part:

with:
  ref: ${{ github.event.pull_request.head.sha }}

Won't the Action re-run with the latest commit by default when the PR is updated?

lunelson commented 4 years ago

@JakePartusch yeah sorry that's a Lighthouse specific fix, and I can't find the link any more to the issue thread about it, but the Lighthouse CI Github App was not picking up the reference, so the status-check update (posting the results back to the list of checks, after the netlify checks) wasn't coming through, you'd still have to dig through the action output to find the URL of the report. With this fix, it posts the status update

jithindasad commented 4 years ago

@JakePartusch you can find the fix here https://github.com/GoogleChrome/lighthouse-ci/issues/172