Use the ref api to check if a tag exists

This commit is contained in:
Spikatrix 2023-06-10 05:46:02 +00:00
parent 212d4babf8
commit f47fb36ff1

View File

@ -7,7 +7,7 @@ import * as path from 'path'
import * as glob from 'glob' import * as glob from 'glob'
import {retry} from '@lifeomic/attempt' import {retry} from '@lifeomic/attempt'
const getTag = 'GET /repos/{owner}/{repo}/git/tags/{tag_sha}' as const const getRef = 'GET /repos/{owner}/{repo}/git/ref/{ref}' as const
const releaseByTag = 'GET /repos/{owner}/{repo}/releases/tags/{tag}' as const const releaseByTag = 'GET /repos/{owner}/{repo}/releases/tags/{tag}' as const
const createRelease = 'POST /repos/{owner}/{repo}/releases' as const const createRelease = 'POST /repos/{owner}/{repo}/releases' as const
const updateRelease = const updateRelease =
@ -52,10 +52,10 @@ async function get_release_by_tag(
) )
if (target_commit) { if (target_commit) {
try { try {
await octokit.request(getTag, { await octokit.request(getRef, {
...repo(), ...repo(),
tag_sha: tag ref: `tags/${tag}`
}); })
core.warning(`Ignoring target_commit as the tag ${tag} already exists`) core.warning(`Ignoring target_commit as the tag ${tag} already exists`)
} catch (tagError: any) { } catch (tagError: any) {
if (tagError.status !== 404) { if (tagError.status !== 404) {