Skip to content

feat!: run on push and checkout release PR head commit#67

Merged
sparten11740 merged 10 commits intomasterfrom
sparten11740/feat/run-on-master-find-head-ref
Dec 10, 2025
Merged

feat!: run on push and checkout release PR head commit#67
sparten11740 merged 10 commits intomasterfrom
sparten11740/feat/run-on-master-find-head-ref

Conversation

@sparten11740
Copy link
Collaborator

@sparten11740 sparten11740 commented Dec 10, 2025

This refactors the publish action to be able to run on push in the context of the base branch. It identifies the commit's corresponding pull request to checkout its head commit. Most of our repositories are configured to delete PR branches after merging, which stops us from checking out the head SHA directly.

We need to filter a bit different to avoid running to often (e.g. on push to irrelevant PR branches). The following worked well in the test repo:

if: github.event_name == 'workflow_dispatch' || (contains(github.event.head_commit.message, format('chore{0} release', ':')) && ! startsWith(github.ref, 'refs/tags/'))

Test Plan

Successful run in https://github.com/ExodusMovement/actions-playground/actions/runs/20093513534/job/57646239041

@sparten11740 sparten11740 self-assigned this Dec 10, 2025
@sparten11740 sparten11740 force-pushed the sparten11740/feat/run-on-master-find-head-ref branch 2 times, most recently from 2bd1dd0 to fb55b2c Compare December 10, 2025 05:02
@sparten11740 sparten11740 changed the title feat: run from master and checkout release PRs head commit feat!: run on push and checkout release PRs head commit Dec 10, 2025
@sparten11740 sparten11740 changed the title feat!: run on push and checkout release PRs head commit feat!: run on push and checkout release PR head commit Dec 10, 2025
@sparten11740 sparten11740 force-pushed the sparten11740/feat/run-on-master-find-head-ref branch 20 times, most recently from 165e269 to fea6c27 Compare December 10, 2025 07:57
@sparten11740 sparten11740 force-pushed the sparten11740/feat/run-on-master-find-head-ref branch from fea6c27 to ea085f9 Compare December 10, 2025 08:18
@sparten11740 sparten11740 marked this pull request as ready for review December 10, 2025 09:30
sha,
})
} catch (e) {
if (e instanceof Error && e.message.includes('Reference already exists')) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

non-blocking: they don't provide an error code or something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there might be one, checking

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unfortunately no, this is the whole body they return:

{
    "message": "Reference already exists",
    "documentation_url": "https://docs.github.com/rest/git/refs#create-a-reference",
    "status": "422"
}

@sparten11740 sparten11740 merged commit eaa71b2 into master Dec 10, 2025
2 checks passed
@sparten11740 sparten11740 deleted the sparten11740/feat/run-on-master-find-head-ref branch December 10, 2025 13:33
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

Successfully merging this pull request may close these issues.

2 participants