Open apeacock1991 opened 1 year ago
Had the same issue. However, did something a bit different to OP as workaround:
github.ref_name
in a pull request refers to the pull request merge branch. Something like 42/merge
. Where 42
is the PR number.
So instead, I've used:
branch: ${{ github.head_ref || github.ref_name }}
github.head_ref
refers to the base branch if being triggered in a pull request (i.e. feat-do-some-work
). And if not a pull request, assume it's a push
workflow and then github.ref_name
is the branch that was pushed (i.e. main
).
Indeed github.head_ref || github.ref_name
is what the action actually tries to do
Btw I'm using reusable workflows. Maybe that's the source of the issue
I ran into the same issue (not using reusable workflows). Without setting the branch in config, deploys run on pull_request were all named HEAD.
Setting to branch: ${{ github.head_ref || github.ref_name }}
gives me the source branch on pull_request and the branch name on push 🙌
Same problem for me, fixed by the previous comment. Here's my full config for future ref:
- name: Build web
run: |
if [ "$GITHUB_REF_NAME" == "main" ]; then
npm run build:web:prod
elif [ "$GITHUB_REF_NAME" == "staging" ]; then
npm run build:web:staging
else
npm run build:web
fi
- name: Publish site
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: ${{ matrix.cf-project }}
directory: www
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.head_ref || github.ref_name }}
Also, when the event is triggered by pushing a tag, the Cloudflare deployments just show HEAD
Got this exact same issue
I have this issue as well.
Based on the documentation, if you omit branch, it should default to the branch for the workflow.
I omitted the parameter, but it always reported deployments in the dashboard to master. Passing the branch using
branch: ${{ github.ref_name }}
fixed this, but the docs either need updating or the code fixing.