Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: replaced the ref sent to Vercel set in githubCommitRef by the branch name #232

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

Elindorath
Copy link
Contributor

@Elindorath Elindorath commented Aug 26, 2022

When deploying on a commit event, the ref is in the form refs/heads/${branch} (see github context docs) which is not consistent with the way Vercel works

@BetaHuhnBot
Copy link
Collaborator

⚠️ This PR has not seen any activity in the past 2 months so I'm marking it as stale. I'll close it if it doesn't see any activity in the coming week.

@BetaHuhnBot BetaHuhnBot added the wontfix This will not be worked on label Oct 26, 2022
@Elindorath
Copy link
Contributor Author

Just preventing the bot to close this

@BetaHuhnBot BetaHuhnBot removed the wontfix This will not be worked on label Nov 2, 2022
@BetaHuhnBot
Copy link
Collaborator

⚠️ This PR has not seen any activity in the past 2 months so I'm marking it as stale. I'll close it if it doesn't see any activity in the coming week.

@BetaHuhnBot BetaHuhnBot added the wontfix This will not be worked on label Jan 2, 2023
@Elindorath
Copy link
Contributor Author

Once again, just preventing the bot to close this. @BetaHuhn could you please check this out?

@BetaHuhnBot BetaHuhnBot removed the wontfix This will not be worked on label Jan 6, 2023
@BetaHuhnBot
Copy link
Collaborator

⚠️ This PR has not seen any activity in the past 2 months so I'm marking it as stale. I'll close it if it doesn't see any activity in the coming week.

@BetaHuhnBot BetaHuhnBot added the wontfix This will not be worked on label Mar 7, 2023
@Elindorath
Copy link
Contributor Author

Once again, just preventing the bot to close this. @BetaHuhn could you please check this out?

@BetaHuhnBot BetaHuhnBot removed the wontfix This will not be worked on label Mar 14, 2023
@BetaHuhn
Copy link
Owner

BetaHuhn commented Mar 16, 2023

which is not consistent with the way Vercel works

@Elindorath could you elaborate on this?

@wagnertimo
Copy link

@BetaHuhn
When github.ref is used (e.g. push trigger), then GH adds the prefix refs/heads/ (e.g. push on foo-bar outputs ref context refs/heads/foo-bar ). This will be visible in the Vercel deployments instead of the 'clear' branch name, e.g. foo-bar (which the default GitHub Action Vercel Bot is using/showing). PR triggers with github.head_ref are not adding the prefix, just the branch name.

One huge issue (despite the cosmetics) comes with the use of preview environments per branch on Vercel. You cannot link a preview environment variable to the deployed branch refs/heads/foo-bar. This is can't be found on Vercel when the project is linked with GitHub; only foo-bar.

I hope this helps 😃

@Elindorath
Copy link
Contributor Author

Oops, sorry, didn't see your question @BetaHuhn
But I see wagnertimo did a good job at explaining the issue 😉 Thanks

dist/index.js Outdated
@@ -16001,7 +16001,7 @@ const setDynamicVars = () => {
context.ACTOR = github.context.actor
context.REF = github.context.ref
context.SHA = github.context.sha
context.BRANCH = github.context.ref.substr(11)
context.BRANCH = github.context.ref.substring(11)

Choose a reason for hiding this comment

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

Maybe one could even be more explicit and state where the 11 char length comes from?

Suggested change
context.BRANCH = github.context.ref.substring(11)
context.BRANCH = github.context.ref.substring("refs/heads/".length)

@shehroze-1122
Copy link

shehroze-1122 commented Oct 16, 2023

I am dealing with the same issue where, I have setup staging environment by pointing a preview branch of name staging to a custom domain.
It was working fine with the official vercel app integration but this action prefixes the branch by refs/head which results in vercel not being able to track the staging branch.

@BetaHuhn @wagnertimo please can you guys get this PR merged?

@MartinLupa
Copy link

MartinLupa commented Oct 24, 2023

Is it possible to merge this pr? We are experiencing the same issue. @BetaHuhn @wagnertimo thanks!

@wagnertimo
Copy link

Hey @shehroze-1122 and @MartinLupa thx for your interest and request but unfortunately I am not the owner of this repo and have no permission to merge 😞
Please @BetaHuhn look into this... it's a small but powerful change! Thank you

@EvanNotFound
Copy link

Thanks for all your solutions! I have forked this project and published a fixed version that you can use out of box: https://github.com/EvanNotFound/vercel-deployment-for-github-actions

If you need it, feel free to check it out!

CleanShot 2024-02-18 at 00 21 54@2x

mountainash added a commit to mountainash/deploy-to-vercel-action that referenced this pull request Mar 11, 2024
@Elindorath
Copy link
Contributor Author

Elindorath commented May 13, 2024

I just updated this PR with the last changes on the repo and made the enhancement suggested by @wagnertimo (thanks btw 😉).
@BetaHuhn don't hesitate to tell me if there is something blocking this to be merged.

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.

None yet

7 participants