mirror of
https://github.com/docker/build-push-action.git
synced 2025-04-23 03:26:46 +00:00
Fix ref spec for default Git context
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
parent
c0c3e27be3
commit
19c07384dc
3 changed files with 28 additions and 15 deletions
|
@ -38,9 +38,16 @@ export interface Inputs {
|
|||
|
||||
export function defaultContext(): string {
|
||||
if (!_defaultContext) {
|
||||
let ref = github.context.ref;
|
||||
if (github.context.sha && ref && !ref.startsWith('refs/')) {
|
||||
ref = `refs/heads/${github.context.ref}`;
|
||||
}
|
||||
if (github.context.sha && !ref.startsWith(`refs/pull/`)) {
|
||||
ref = github.context.sha;
|
||||
}
|
||||
_defaultContext = `${process.env.GITHUB_SERVER_URL || 'https://github.com'}/${github.context.repo.owner}/${
|
||||
github.context.repo.repo
|
||||
}.git#${github.context?.ref?.replace(/^refs\//, '')}`;
|
||||
}.git#${ref}`;
|
||||
}
|
||||
return _defaultContext;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue