A GitHub Action to ensure the triggering commit is still at the tip of a given branch
This action acts as a filter for push
-based actions to ensure that the triggering event meets the following qualifications:
This helps prevent subtle race conditions when multiple commits or PRs are committed or merged to master and multiple workflows that automatically deploy changes run simultaneously, since only the most recently created commit will pass the check.
In your workflow:
action "your-action" {
uses = "BinaryMuse/tip-of-branch@master"
args = "master"
secrets = [ "GITHUB_TOKEN" ]
}
args
can be a single branch, or can be multiple branches if you want to match any of them:
action "your-action" {
uses = "BinaryMuse/tip-of-branch@master"
args = [ "master", "some-other-branch" ]
secrets = [ "GITHUB_TOKEN" ]
}
You must include the GITHUB_TOKEN
secret in order for the action to reach the API and ensure that the commit is still at the head of the branch.