Merge pull request #347 from crazy-max/fix-ref-spec

Fix ref spec for default Git context
This commit is contained in:
CrazyMax 2021-05-26 13:00:32 +02:00 committed by GitHub
commit 74242a33cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 15 deletions

View file

@ -39,9 +39,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;
}