Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential race condition with GitHub actions #185

Open
gmlueck opened this issue Apr 1, 2024 · 1 comment
Open

Potential race condition with GitHub actions #185

gmlueck opened this issue Apr 1, 2024 · 1 comment

Comments

@gmlueck
Copy link
Contributor

gmlueck commented Apr 1, 2024

I think there is a potential race condition with the "'publish-pages" job I added to GitHub actions in #184.

The danger occurs when there are multiple pushes (i.e. merged PRs) to the "main" branch in close succession. I added concurrency to the publishing job to prevent overlapping deployments to the web site. I think this makes sense because overlapping deployments could interfere with one another, causing corruption to the deployed web content.

However, there is no guarantee that the latest push will be published. Consider the following scenario when two PRs are merged in close succession:

  • PR 1 is merged first, GitHub actions starts running
  • PR 2 is merged next, GitHub actions starts running
  • PR 2 happens to reach the "publish-pages" job first, and deploys
  • PR 1 waits for PR 2 to complete, and then it executes "publish-pages"

As a result, changes from PR 2 are not published to the web site.

It seems like this could be fixed by adding an if condition to the "publish-pages" job which skips the job unless the SHA of the "push" event that triggers the workflow is currently the head of the "main" branch.

I'm not much of an expert in GitHub actions. @oddhack or @outofcontrol do you happen to know this stuff better? Is the solution I suggest the right way to fix this?

@oddhack
Copy link

oddhack commented Apr 1, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants