This repository demonstrates the issue with using ref: ${{ github.ref }} in GitHub Actions checkout steps for pull requests.
In ArmoniK.Core workflows, all checkout actions use:
- uses: actions/checkout@v4
with:
ref: ${{ github.ref }} # ← PROBLEMATIC!This causes issues with pull requests because:
github.ref=refs/heads/main✅ Works fine
github.ref=refs/pull/123/merge❌ Problematic- This ref exists in the base repository but not in the fork
- Can checkout wrong code or fail entirely
Remove ref: ${{ github.ref }} entirely!
- uses: actions/checkout@v4
# No ref parameter - let GitHub Actions decide automaticallyGitHub Actions automatically:
- On
push: checks out the pushed branch - On
pull_request: checks out the PR merge commit (PR code + base branch merged) - Works correctly for both internal and fork PRs
-
On Push to main:
- Both jobs will succeed
- Both show the same commit
-
On Pull Request (internal or fork):
- Compare the outputs of both jobs
- The job WITHOUT
refwill show the correct merge commit - The job WITH
refmay show different behavior or fail
- Push this repository to GitHub
- Create a pull request
- Check the GitHub Actions output
- Compare the two jobs to see the difference
The workflow will show side-by-side:
- ✅ Correct behavior (without ref)
- ❌ Problematic behavior (with ref)
This proves that removing ref: ${{ github.ref }} from ArmoniK.Core workflows will fix PR support.