Repository navigation
fix: skip unconfigured pulls when creating branches #808
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
base: main
Are you sure you want to change the base?
Changes from all commits
c0db58c
3ac5e8e
66ea3a8
d1c5a36
cac644d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,6 +22,7 @@ import { | |||||||||||||||||||||||||||
| pickGitIdentityConfig, | ||||||||||||||||||||||||||||
| resolveBaseDir, | ||||||||||||||||||||||||||||
| safeInfo, | ||||||||||||||||||||||||||||
| usesImplicitPullTarget, | ||||||||||||||||||||||||||||
| } from './util'; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const cwdInput = getInput('cwd') || ''; | ||||||||||||||||||||||||||||
|
|
@@ -159,6 +160,7 @@ safeInfo(`Running in ${baseDir}`); | |||||||||||||||||||||||||||
| } else safeInfo('> Not fetching repo.'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const targetBranch = getInput('new_branch'); | ||||||||||||||||||||||||||||
| let branchCreated = false; | ||||||||||||||||||||||||||||
| if (targetBranch) { | ||||||||||||||||||||||||||||
| safeInfo('> Checking-out branch...'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -167,20 +169,27 @@ safeInfo(`Running in ${baseDir}`); | |||||||||||||||||||||||||||
| 'Creating a new branch without fetching the repo first could result in an error when pushing to GitHub. Refer to the action README for more info about this topic.', | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await git | ||||||||||||||||||||||||||||
| branchCreated = await git | ||||||||||||||||||||||||||||
| .checkout([targetBranch]) | ||||||||||||||||||||||||||||
| .then(() => { | ||||||||||||||||||||||||||||
| log(undefined, `'${targetBranch}' branch already existed.`); | ||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||
| .catch(() => { | ||||||||||||||||||||||||||||
| .catch(async () => { | ||||||||||||||||||||||||||||
| log(undefined, `Creating '${targetBranch}' branch.`); | ||||||||||||||||||||||||||||
| return git.checkout(['-b', targetBranch], log); | ||||||||||||||||||||||||||||
| await git.checkout(['-b', targetBranch], log); | ||||||||||||||||||||||||||||
| return true; | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const pullOption = parseBoolOrGitArgs('pull'); | ||||||||||||||||||||||||||||
| const pullArgs = parseGitArgs(pullOption === true ? '' : pullOption || ''); | ||||||||||||||||||||||||||||
| if (pullOption) { | ||||||||||||||||||||||||||||
| await pullFromRemote(pullOption, {restage: true, ignoreErrors}); | ||||||||||||||||||||||||||||
| await pullFromRemote(pullArgs, { | ||||||||||||||||||||||||||||
| restage: true, | ||||||||||||||||||||||||||||
| ignoreErrors, | ||||||||||||||||||||||||||||
| createdBranch: branchCreated ? targetBranch : undefined, | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| } else safeInfo('> Not pulling from repo.'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| safeInfo('> Creating commit...'); | ||||||||||||||||||||||||||||
|
|
@@ -200,6 +209,22 @@ safeInfo(`Running in ${baseDir}`); | |||||||||||||||||||||||||||
| setOutput('commit_long_sha', data.commit); | ||||||||||||||||||||||||||||
| setOutput('commit_sha', data.commit.substring(0, 7)); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| let pushOption: string | boolean; | ||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||
| pushOption = getInput('push', true); | ||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||
| pushOption = getInput('push'); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| const pushAttempts = pushOption | ||||||||||||||||||||||||||||
| ? parsePushAttempts(getInput('push_attempts') || '1') | ||||||||||||||||||||||||||||
| : 0; | ||||||||||||||||||||||||||||
| const tagArgs = parseGitArgs(getInput('tag') || ''); | ||||||||||||||||||||||||||||
| const mayRetag = | ||||||||||||||||||||||||||||
| tagArgs.length > 0 && Boolean(pullOption) && pushAttempts > 1; | ||||||||||||||||||||||||||||
| let head = data.commit; | ||||||||||||||||||||||||||||
| const tagName = tagArgs.find(arg => !arg.startsWith('-')); | ||||||||||||||||||||||||||||
| const tagRef = mayRetag && tagName ? 'refs/tags/' + tagName : undefined; | ||||||||||||||||||||||||||||
| let retryTag: string | undefined; | ||||||||||||||||||||||||||||
| if (getInput('tag')) { | ||||||||||||||||||||||||||||
| safeInfo('> Tagging commit...'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -208,35 +233,30 @@ safeInfo(`Running in ${baseDir}`); | |||||||||||||||||||||||||||
| 'Creating a tag without fetching the repo first could result in an error when pushing to GitHub. Refer to the action README for more info about this topic.', | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| await git | ||||||||||||||||||||||||||||
| .tag(parseGitArgs(getInput('tag') || ''), (err, data?) => { | ||||||||||||||||||||||||||||
| if (data) setOutput('tagged', 'true'); | ||||||||||||||||||||||||||||
| return log(err, data); | ||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||
| .then(data => { | ||||||||||||||||||||||||||||
| setOutput('tagged', 'true'); | ||||||||||||||||||||||||||||
| return log(null, data); | ||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||
| .catch(err => core.setFailed(err)); | ||||||||||||||||||||||||||||
| // Identify only the tag this invocation created or replaced at HEAD. | ||||||||||||||||||||||||||||
| // Keep tagging before the push so custom atomic branch/tag pushes work. | ||||||||||||||||||||||||||||
| const previousTag = tagRef && (await tagAtCommit(tagRef, head)); | ||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||
| log(null, await git.tag(tagArgs)); | ||||||||||||||||||||||||||||
| setOutput('tagged', 'true'); | ||||||||||||||||||||||||||||
| if (tagRef) { | ||||||||||||||||||||||||||||
| const tagged = await tagAtCommit(tagRef, head); | ||||||||||||||||||||||||||||
| if (tagged !== previousTag) retryTag = tagged; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||||||
| core.setFailed(err instanceof Error ? err : String(err)); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } else safeInfo('> No tag info provided.'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| let pushOption: string | boolean; | ||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||
| pushOption = getInput('push', true); | ||||||||||||||||||||||||||||
| } catch { | ||||||||||||||||||||||||||||
| pushOption = getInput('push'); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| if (pushOption) { | ||||||||||||||||||||||||||||
| const pushAttempts = parsePushAttempts(getInput('push_attempts') || '1'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| for (let attempt = 1; attempt <= pushAttempts; attempt++) { | ||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||
| safeInfo( | ||||||||||||||||||||||||||||
| pushAttempts > 1 | ||||||||||||||||||||||||||||
| ? `> Pushing commit to repo (attempt ${attempt}/${pushAttempts})...` | ||||||||||||||||||||||||||||
| : '> Pushing commit to repo...', | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| await pushCommit(pushOption); | ||||||||||||||||||||||||||||
| await pushCommit(pushOption, mayRetag); | ||||||||||||||||||||||||||||
| break; | ||||||||||||||||||||||||||||
| } catch (err) { | ||||||||||||||||||||||||||||
| if (attempt === pushAttempts) throw err; | ||||||||||||||||||||||||||||
|
|
@@ -247,14 +267,28 @@ safeInfo(`Running in ${baseDir}`); | |||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| if (pullOption) { | ||||||||||||||||||||||||||||
| await pullFromRemote(pullOption, { | ||||||||||||||||||||||||||||
| await pullFromRemote(pullArgs, { | ||||||||||||||||||||||||||||
| restage: false, | ||||||||||||||||||||||||||||
| ignoreErrors, | ||||||||||||||||||||||||||||
| createdBranch: branchCreated ? targetBranch : undefined, | ||||||||||||||||||||||||||||
| retryFromOrigin: pushOption === true, | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| // Rebase rewrites the commit; refresh outputs from HEAD. | ||||||||||||||||||||||||||||
| const head = (await git.revparse(['HEAD'])).trim(); | ||||||||||||||||||||||||||||
| const previousHead = head; | ||||||||||||||||||||||||||||
| head = (await git.revparse(['HEAD'])).trim(); | ||||||||||||||||||||||||||||
| setOutput('commit_long_sha', head); | ||||||||||||||||||||||||||||
| setOutput('commit_sha', head.substring(0, 7)); | ||||||||||||||||||||||||||||
| if (tagRef && retryTag && head !== previousHead) { | ||||||||||||||||||||||||||||
| if ((await tagAtCommit(tagRef, previousHead)) !== retryTag) | ||||||||||||||||||||||||||||
| throw new Error('The local tag changed during the push retry.'); | ||||||||||||||||||||||||||||
| // Reapply the original target, annotation and signing options. | ||||||||||||||||||||||||||||
| // An explicitly pinned target stays pinned. | ||||||||||||||||||||||||||||
| const args = [...tagArgs]; | ||||||||||||||||||||||||||||
| const end = args.indexOf('--'); | ||||||||||||||||||||||||||||
| args.splice(end < 0 ? args.length : end, 0, '--force'); | ||||||||||||||||||||||||||||
| await git.tag(args); | ||||||||||||||||||||||||||||
| retryTag = await tagAtCommit(tagRef, head); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
@@ -332,10 +366,13 @@ async function logDryRunRemainingSteps() { | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| const pullOption = parseBoolOrGitArgs('pull'); | ||||||||||||||||||||||||||||
| if (pullOption) { | ||||||||||||||||||||||||||||
| const pullArgs = parseGitArgs(pullOption === true ? '' : pullOption); | ||||||||||||||||||||||||||||
| safeInfo( | ||||||||||||||||||||||||||||
| `> Would pull from remote${ | ||||||||||||||||||||||||||||
| pullOption === true ? '' : ` with: ${pullOption}` | ||||||||||||||||||||||||||||
| }.`, | ||||||||||||||||||||||||||||
| targetBranch && usesImplicitPullTarget(pullArgs) | ||||||||||||||||||||||||||||
| ? ' unless a new branch is created without an upstream' | ||||||||||||||||||||||||||||
| : '' | ||||||||||||||||||||||||||||
| }${pullOption === true ? '' : ` with: ${pullOption}`}.`, | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| } else safeInfo('> Would not pull from repo.'); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -389,19 +426,110 @@ async function logDryRunRemainingSteps() { | |||||||||||||||||||||||||||
| } else safeInfo('> Would not push anything.'); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| async function tagAtCommit(ref: string, commit: string) { | ||||||||||||||||||||||||||||
| const tags = await git.raw([ | ||||||||||||||||||||||||||||
| 'for-each-ref', | ||||||||||||||||||||||||||||
| '--points-at=' + commit, | ||||||||||||||||||||||||||||
| '--format=%(refname) %(objectname)', | ||||||||||||||||||||||||||||
| '--', | ||||||||||||||||||||||||||||
| ref, | ||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||
| return tags | ||||||||||||||||||||||||||||
| .trim() | ||||||||||||||||||||||||||||
| .split('\n') | ||||||||||||||||||||||||||||
| .find(line => line.startsWith(ref + ' ')); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| async function findRemoteBranch(destination: string) { | ||||||||||||||||||||||||||||
| const full = destination.startsWith('refs/'); | ||||||||||||||||||||||||||||
| if (full && !destination.startsWith('refs/heads/')) throw explicitPullError(); | ||||||||||||||||||||||||||||
| const refs = ( | ||||||||||||||||||||||||||||
| await git.listRemote([ | ||||||||||||||||||||||||||||
| '--refs', | ||||||||||||||||||||||||||||
| '--', | ||||||||||||||||||||||||||||
| 'origin', | ||||||||||||||||||||||||||||
| destination, | ||||||||||||||||||||||||||||
| ...(full ? [] : [destination + '/HEAD']), | ||||||||||||||||||||||||||||
| ]) | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| .trim() | ||||||||||||||||||||||||||||
| .split('\n') | ||||||||||||||||||||||||||||
| .map(line => line.split('\t')[1]); | ||||||||||||||||||||||||||||
| if (full) return refs.includes(destination) ? destination : undefined; | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Match Git’s push destination rules for qualified names too. With
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| // Git gives branches, tags and exact names priority over remote-tracking | ||||||||||||||||||||||||||||
| // refs. ls-remote also returns suffix matches, which must be ignored. | ||||||||||||||||||||||||||||
| const strong = [ | ||||||||||||||||||||||||||||
| destination, | ||||||||||||||||||||||||||||
| 'refs/' + destination, | ||||||||||||||||||||||||||||
| 'refs/heads/' + destination, | ||||||||||||||||||||||||||||
| 'refs/tags/' + destination, | ||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||
| const matches = refs.filter(ref => strong.includes(ref)); | ||||||||||||||||||||||||||||
| if (matches.length === 1 && matches[0].startsWith('refs/heads/')) | ||||||||||||||||||||||||||||
| return matches[0]; | ||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||
| matches.length || | ||||||||||||||||||||||||||||
| refs.includes('refs/remotes/' + destination) || | ||||||||||||||||||||||||||||
| refs.includes('refs/remotes/' + destination + '/HEAD') | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| throw explicitPullError(); | ||||||||||||||||||||||||||||
| return undefined; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| function explicitPullError() { | ||||||||||||||||||||||||||||
| return new Error( | ||||||||||||||||||||||||||||
| 'Set an explicit pull target for an ambiguous or non-branch push destination.', | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| async function pullFromRemote( | ||||||||||||||||||||||||||||
| pullOption: true | string, | ||||||||||||||||||||||||||||
| args: string[], | ||||||||||||||||||||||||||||
| options: { | ||||||||||||||||||||||||||||
| restage: boolean; | ||||||||||||||||||||||||||||
| ignoreErrors: 'all' | 'pathspec' | 'none'; | ||||||||||||||||||||||||||||
| createdBranch?: string; | ||||||||||||||||||||||||||||
| retryFromOrigin?: boolean; | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||
| if (options.createdBranch && usesImplicitPullTarget(args)) { | ||||||||||||||||||||||||||||
| // A configured pull target may have no local tracking-ref mapping when | ||||||||||||||||||||||||||||
| // remote.fetch is narrow. Let Git resolve it rather than treating it as absent. | ||||||||||||||||||||||||||||
| const upstream = await git.getConfig( | ||||||||||||||||||||||||||||
| `branch.${options.createdBranch}.merge`, | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| if (upstream.value === null) { | ||||||||||||||||||||||||||||
| // The default push explicitly selects origin. Custom push commands | ||||||||||||||||||||||||||||
| // need an explicit pull target; do not guess their remote or refspec. | ||||||||||||||||||||||||||||
| if (!options.retryFromOrigin) { | ||||||||||||||||||||||||||||
| safeInfo('> Skipping pull because the new branch has no upstream.'); | ||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| const localRef = `refs/heads/${options.createdBranch}`; | ||||||||||||||||||||||||||||
| // A source-only push uses remote.origin.push to expand its destination. | ||||||||||||||||||||||||||||
| // Ask Git for the remote ref, even if there is no local tracking ref. | ||||||||||||||||||||||||||||
| const mappedRef = await git.raw([ | ||||||||||||||||||||||||||||
| '-c', | ||||||||||||||||||||||||||||
| `branch.${options.createdBranch}.pushRemote=origin`, | ||||||||||||||||||||||||||||
| 'for-each-ref', | ||||||||||||||||||||||||||||
| '--format=%(push:remoteref)', | ||||||||||||||||||||||||||||
| '--', | ||||||||||||||||||||||||||||
| localRef, | ||||||||||||||||||||||||||||
| ]); | ||||||||||||||||||||||||||||
| const remoteRef = await findRemoteBranch(mappedRef.trim() || localRef); | ||||||||||||||||||||||||||||
| if (!remoteRef) { | ||||||||||||||||||||||||||||
| safeInfo( | ||||||||||||||||||||||||||||
| '> Skipping pull because the new branch is not on origin yet.', | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| return; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| args = [...args, 'origin', remoteRef]; | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| safeInfo('> Pulling from remote...'); | ||||||||||||||||||||||||||||
| const args = pullOption === true ? '' : pullOption; | ||||||||||||||||||||||||||||
| core.debug(`Current git pull arguments: ${args}`); | ||||||||||||||||||||||||||||
| await git | ||||||||||||||||||||||||||||
| .fetch(undefined, log) | ||||||||||||||||||||||||||||
| .pull(undefined, undefined, parseGitArgs(args), log); | ||||||||||||||||||||||||||||
| core.debug(`Current git pull arguments: ${args.join(' ')}`); | ||||||||||||||||||||||||||||
| await git.fetch(undefined, log).pull(undefined, undefined, args, log); | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not fetch an unrelated remote before the synthesized pull. If
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| safeInfo('> Checking for conflicts...'); | ||||||||||||||||||||||||||||
| const status = await git.status(undefined, log); | ||||||||||||||||||||||||||||
|
|
@@ -424,29 +552,36 @@ async function pullFromRemote( | |||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| async function pushCommit(pushOption: true | string) { | ||||||||||||||||||||||||||||
| async function pushCommit(pushOption: true | string, mayRetag: boolean) { | ||||||||||||||||||||||||||||
| if (pushOption === true) { | ||||||||||||||||||||||||||||
| // With push.followTags enabled, Git can publish an annotated tag even when | ||||||||||||||||||||||||||||
| // it rejects the branch. The separate tag push publishes it after success. | ||||||||||||||||||||||||||||
| const options = ['--set-upstream']; | ||||||||||||||||||||||||||||
| if (mayRetag) options.push('--no-follow-tags'); | ||||||||||||||||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Keep explicitly mapped retry tags out of non-atomic branch pushes. Without Handle explicit tag mappings before the first push. Either defer the tracked tag until branch success or require an atomic push for that configuration. Preserve mappings for unrelated refs.
|
||||||||||||||||||||||||||||
| const branch = getInput('new_branch'); | ||||||||||||||||||||||||||||
| // Without an explicit source, configured push refspecs can publish tags | ||||||||||||||||||||||||||||
| // even with --no-follow-tags. Reject all mapped updates together. | ||||||||||||||||||||||||||||
| if ( | ||||||||||||||||||||||||||||
| mayRetag && | ||||||||||||||||||||||||||||
| !branch && | ||||||||||||||||||||||||||||
| (await git.getConfig('remote.origin.push')).value | ||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||
| options.push('--atomic'); | ||||||||||||||||||||||||||||
|
Comment on lines
+564
to
+569
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mirror remotes can publish retry tags without atomic protection. With Include mirror mode in the atomic guard: Suggested fix
Committable suggestion
|
||||||||||||||||||||||||||||
| if (branch) { | ||||||||||||||||||||||||||||
| core.debug(`Running: git push --set-upstream origin -- ${branch}`); | ||||||||||||||||||||||||||||
| core.debug(`Running: git push ${options.join(' ')} origin -- ${branch}`); | ||||||||||||||||||||||||||||
| await git.raw( | ||||||||||||||||||||||||||||
| ['push', '--set-upstream', 'origin', '--', branch], | ||||||||||||||||||||||||||||
| ['push', ...options, 'origin', '--', branch], | ||||||||||||||||||||||||||||
| (err, data?) => { | ||||||||||||||||||||||||||||
| if (data) setOutput('pushed', 'true'); | ||||||||||||||||||||||||||||
| return log(err, data); | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||
| core.debug('Running: git push origin --set-upstream'); | ||||||||||||||||||||||||||||
| await git.push( | ||||||||||||||||||||||||||||
| 'origin', | ||||||||||||||||||||||||||||
| undefined, | ||||||||||||||||||||||||||||
| {'--set-upstream': null}, | ||||||||||||||||||||||||||||
| (err, data?) => { | ||||||||||||||||||||||||||||
| if (data) setOutput('pushed', 'true'); | ||||||||||||||||||||||||||||
| return log(err, data); | ||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||
| core.debug(`Running: git push origin ${options.join(' ')}`); | ||||||||||||||||||||||||||||
| await git.push('origin', undefined, options, (err, data?) => { | ||||||||||||||||||||||||||||
| if (data) setOutput('pushed', 'true'); | ||||||||||||||||||||||||||||
| return log(err, data); | ||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||
| core.debug(`Running: git push ${pushOption}`); | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Track the tag object created by the action, not the next value of the ref.
If another local writer replaces the new annotated
releasetag with a different annotation at the same commit before this lookup,retryTagrecords the other writer’s tag. After a rebase, the ownership check accepts that tag and the action overwrites it. Carry the object ID produced by the tag creation operation into the retry. Reading the ref again cannot establish which writer created that object. (raw.githubusercontent.com)