wait-for-netlify-action
wait-for-netlify-action copied to clipboard
Does not reliably work when adding a commit to an existing deploy preview
The following workflow does not reliably work with wait-for-netlify-action:
- Create a branch
test
- Push the branch to origin and create a PR
- Deploys the website
- Waits for 200 on deploy preview
- Proceed with additional scripts (e.g. Lighthouse) => As expected
- Add a new commit on branch
test
- Push the commit to origin
- Waits for 200 on deploy preview immediately gives an "ok" because the previous deploy is still online
- 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.
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) 🤔
Sounds great! @JakePartusch quite busy at the moment, but I'd love to investigate that as soon as I find some time.
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)
- use fountainhead/action-wait-for-check to wait netlify deploy check.
- run wait-for-netlify-action after check done
1. find out your "pull request's netlify's Pages changed checkname
steps
- go to one of pull request
- go to Checks tab
- there is a netlify checks on left list
- copy "Pages changed ... " checkname
- e.x. "Pages changed - modest-spence-711b92"
2. fill in your checkname (with single quote, bcuz checkName string have space)
steps
- e.x.
checkName: 'Pages changed - modest-spence-711b92'
and
-
if: steps.wait-for-Netlify.outputs.conclusion == 'neutral'
finally
- create pull request, push new commit and test
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/[email protected]
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
- there are four netlify check names when preview deploy
- Header rules - modest-spence-...
- Pages changed - modest-spence-...
- Redirect rules - modest-spence-...
- Mixed content - modest-spence-...
I chose 'Pages changed' as check target by intuition
- rest of checks seems do nothing
- and I don't know why 'Pages changed' check's final conclusion is 'neutral'
- why is not 'success', like 'Mixed content' check
The things I want to say is
As long as your netlify USE CASE become more COMPLICATE in the future
- maybe there will be another more appropriate check name can use (e.x. deploy check?)
- maybe the conclusion become 'success', but NOT 'neutral'
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.
- https://webcloud.se/blog/2020-02-16-github-actions-preview-deploys/
In this post said
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
- I can not find too much information on
- https://community.netlify.com/
- https://docs.netlify.com/
- 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 !!!
@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?
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