Skip to content

Conversation

lidel
Copy link
Member

@lidel lidel commented Aug 24, 2025

splits workflow to enable ipfs deployments for all pull requests including those from forks
this approach is based on https://github.com/ipfs/specs where we conformed this approach works (PR from fork example: ipfs/specs#331 (comment))

splits workflow to enable ipfs deployments for all pull requests
including those from forks

- build.yml: builds site and uploads artifacts
- deploy.yml: handles ipfs deployment via workflow_run
- uses ipfs-deploy-action@b491fdc with workflow_run support
@lidel lidel requested a review from 2color August 24, 2025 00:36
Copy link
Contributor

github-actions bot commented Aug 24, 2025

🚀 Build Preview on IPFS ready

@lidel lidel marked this pull request as ready for review August 24, 2025 00:38
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
# No ref parameter needed - uses correct ref automatically:
# - For PRs: merge commit or PR head
Copy link
Member

Choose a reason for hiding this comment

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

How is it decided if it's the merge commit or PR head?

Copy link
Member

@2color 2color Aug 24, 2025

Choose a reason for hiding this comment

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

According to the docs, it defaults to the merge commit, which may seem confusing, because it doesn't reflect the actual HEAD state of the PR branch. Instead, it contains PR changes PLUS any new commits that landed on main since the PR was created.

Copy link
Member Author

Choose a reason for hiding this comment

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

good catch, i made a mental shortcut, clarified in 3872fec

@2color 2color requested a review from Copilot August 24, 2025 12:48
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

pr builds always use merge commit, not pr head
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
# No ref parameter needed - uses correct ref automatically:
Copy link
Member

Choose a reason for hiding this comment

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

This does change the behaviour to checkout the merge commit. I guess there's a reason for this being the default. So let's give it a go and change if needed in the future.

@2color 2color merged commit 8aac010 into main Aug 24, 2025
7 checks passed
@2color 2color deleted the modernize-workflows branch August 24, 2025 13:26
uses: actions/checkout@v4
with:
ref: ${{ github.event_name == 'pull_request_target' && github.event.pull_request.head.sha || github.sha }}
# No ref parameter needed - uses correct ref automatically:
Copy link
Member

Choose a reason for hiding this comment

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

The problem with this, which I just realised, is that this will cause ipfs-deploy-action to set the commit status for merge SHA commits that aren't visible in the pull request.

Both Cloudflare Pages and Vercel use the PR head commit for the following reasons:

  • The preview deployment reflects exactly what's in your feature branch
  • It doesn't include any potential merge conflicts or changes that would result from merging with the target branch
  • Each new commit pushed to the PR branch triggers a new preview deployment from that latest commit

If we want to ensure that PRs are up to date and avoid merge conflicts, we can require branches to be up to date before merging in the branch protection rules in GitHub.

Copy link
Member

Choose a reason for hiding this comment

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

I'm currently testing this in this PR: #2119

Copy link
Member

Choose a reason for hiding this comment

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

For some reason, with #2119 the commit SHA that was used in the PR comment is pull_request.head.sha while the code that was checked out was technically the merge commit SHA (which should be different).

I'm currently investigating why.

Copy link
Member

Choose a reason for hiding this comment

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

I can confirm now that there's a discrepancy between the commit SHA used for the build and the commit SHA used to update the comment.

You can see it here: https://github.com/ipfs/ipfs-docs/actions/runs/17208024892/job/48812841343#step:2:87

It's checking out and building e8daa37, but setting the commit status for a3bd938.

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