rossjrw / pr-preview-action

GitHub Action that deploys a pull request preview to GitHub Pages, similar to Vercel and Netlify, and cleans up after itself.
https://github.com/marketplace/actions/deploy-pr-preview
MIT License
287 stars 46 forks source link

Race condition with build workflow #2

Closed rossjrw closed 1 year ago

rossjrw commented 2 years ago

Just encountered a situation where the build and preview workflow occurred at the same time (during the merge of a PR). They both attempted to write a commit on top of the current gh-pages commit. This resulted in the gh-pages branch moving to the commit that removed the preview for the PR, whereas the commit that deployed the build for the new commit made to the main branch was lost.

I will need to investigate running workflows synchronously.

rossjrw commented 2 years ago

https://medium.com/geekculture/make-github-workflows-run-consecutively-4d98840ed600

use one of:

https://github.com/lewagon/wait-on-check-action https://github.com/fountainhead/action-wait-for-check

make sure that the requested check is not required to have happened/be happening (not all buils will coincide with a preview and vice versa)

these plugins need a token - they recommend PAT, but standard can be used if it's within tolerance:

https://docs.github.com/en/rest/overview/resources-in-the-rest-api#rate-limiting

if advising end user to create a PAT, recommend adherence to security guidelines:

https://docs.github.com/en/actions/security-guides/security-hardening-for-github-actions#using-third-party-actions


All of the above is rubbish. Actual solution: https://github.com/JamesIves/github-pages-deploy-action/pull/1054

rossjrw commented 2 years ago

Possibly fixed in 591779e70aba2ce461521af517b269dac0221c77 - needs confirmation

rossjrw commented 1 year ago

I haven't seen this crop up in ages, so calling it fixed.