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

Does not reliably work when adding a commit to an existing deploy preview #6

Open BrunnerLivio opened 4 years ago

BrunnerLivio commented 4 years ago

The following workflow does not reliably work with wait-for-netlify-action:

  1. Create a branch test
  2. Push the branch to origin and create a PR
  3. Deploys the website
  4. Waits for 200 on deploy preview
  5. Proceed with additional scripts (e.g. Lighthouse) => As expected

  1. Add a new commit on branch test
  2. Push the commit to origin
  3. Waits for 200 on deploy preview immediately gives an "ok" because the previous deploy is still online
  4. The additional scripts still use the old deploy preview (e.g. Lighthouse) => Not as expected

An easy fix to workaround this is sure with a simple sleep:

- name: Sleep
  run: sleep 50

... but that is not really clean since we would need to update the sleep value every time the build step takes more or less time after changes.

JakePartusch commented 4 years ago

Yeah @BrunnerLivio — you are completely right, and it's something that I've noticed as well.

We could potentially create a solution for this by using the "commit" preview instead of the PR preview (every build in Netlify has a unique preview url) 🤔

BrunnerLivio commented 4 years ago

Sounds great! @JakePartusch quite busy at the moment, but I'd love to investigate that as soon as I find some time.

flameddd commented 4 years ago

Hi forks

Thanks yours hard work and great jobs

I want to share my workaround. (I have tested several times, it's seems looks fine)

1. find out your "pull request's netlify's Pages changed checkname

steps

  1. go to one of pull request
  2. go to Checks tab
  3. there is a netlify checks on left list
  4. copy "Pages changed ... " checkname
    • e.x. "Pages changed - modest-spence-711b92"

image
image

2. fill in your checkname (with single quote, bcuz checkName string have space)

steps

and

image

finally

workflow yaml

name: Successful Deploy Action Example

on: [pull_request]

jobs:
  screenshots:
    runs-on: ubuntu-latest
    steps:
    - name: Wait for Pages changed to neutral
      uses: fountainhead/action-wait-for-check@v1.0.0
      id: wait-for-Netlify
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        ref: ${{ github.event.pull_request.head.sha || github.sha }}
        checkName: 'Pages changed - modest-spence-711b92'
    - name: Get Preview URL and generate screenshot after Netlify check done
      if: steps.wait-for-Netlify.outputs.conclusion == 'neutral'
      uses: jakepartusch/wait-for-netlify-action@v1
      id: waitFor200
      with:
        site_name: 'modest-spence-711b92'

About "fountainhead/action-wait-for-check" Action

I chose 'Pages changed' as check target by intuition

The things I want to say is

As long as your netlify USE CASE become more COMPLICATE in the future

bcuz I am totally newbie in netlify, I just want to mention those things I not sure


I have another newbie question

Before I come here ("jakepartusch/wait-for-netlify-action"). I read a blog post.

In this post said
image
image

like this

# .github/workflows/example_workflow.yml
name: Successful Deploy Action Example
on: deployment_status
jobs:
  build:
    if: github.event.deployment_status.state == 'success'
    runs-on: ubuntu-latest
    steps:
      - name: XYZ
        run: npm run xyz
        env:
          DEPLOY_URL: ${{ github.event.deployment_status.target_url }}

BUT I have tried lots of times. workflow NEVER be triggered by deployment_status (or deploymene)

and

  1. I can not find too much information on
  2. There exists some Github Actions like wait-for-netlify-action (like a webhook)

SO, I guess the blog post is Misleading (maybe only Zeit can work)

FOR NOW, we can NOT trigger [deploymene, deployment_status] workflow via netlify Preview deploy, right ?

thanks for your patient, hard work and great Github Actions !!!

markokhman commented 3 years ago

@flameddd thank you sooooo much for this workaround, i have spent a couple hours configuring this before I found this thread and configured it same as you did.

I'm wondering if no one have proposed any other pro solution?

dwjohnston commented 5 days ago

I'd been meaning to create a PR or a work that reliably does a 'wait for netlify deploy on branch preview' but I haven't been getting around to it.

If it's useful, this is the script I'm using that'll poll until it's ready.

https://github.com/dwjohnston/blacksheepcode/blob/master/.github/workflows/scripts/wait-for-netlify-deploy.js