order logic to fail fast appropriately
This commit is contained in:
+12
-10
@@ -21,10 +21,12 @@ export async function run(pathInput: string): Promise<void> {
|
|||||||
core.setFailed(`Could not find Repository.`)
|
core.setFailed(`Could not find Repository.`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (github.context.eventName !== 'release') {
|
if (github.context.eventName !== 'release') {
|
||||||
core.setFailed('Please ensure you have the workflow trigger as release.')
|
core.setFailed('Please ensure you have the workflow trigger as release.')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const releaseId: string = github.context.payload.release.id
|
const releaseId: string = github.context.payload.release.id
|
||||||
const releaseTag: string = github.context.payload.release.tag_name
|
const releaseTag: string = github.context.payload.release.tag_name
|
||||||
// Strip any leading 'v' from the tag in case the release format is e.g. 'v1.0.0' as recommended by GitHub docs
|
// Strip any leading 'v' from the tag in case the release format is e.g. 'v1.0.0' as recommended by GitHub docs
|
||||||
@@ -39,16 +41,6 @@ export async function run(pathInput: string): Promise<void> {
|
|||||||
|
|
||||||
const token: string = process.env.TOKEN!
|
const token: string = process.env.TOKEN!
|
||||||
|
|
||||||
const response = await fetch(
|
|
||||||
process.env.GITHUB_API_URL + '/packages/container-registry-url'
|
|
||||||
)
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error(`Failed to fetch status page: ${response.statusText}`)
|
|
||||||
}
|
|
||||||
const data = await response.json()
|
|
||||||
const registryURL: URL = new URL(data.url)
|
|
||||||
console.log(`Container registry URL: ${registryURL}`)
|
|
||||||
|
|
||||||
// Gather & validate user input
|
// Gather & validate user input
|
||||||
// Paths to be included in the OCI image
|
// Paths to be included in the OCI image
|
||||||
// const paths: string[] = core.getInput('path').split(' ')
|
// const paths: string[] = core.getInput('path').split(' ')
|
||||||
@@ -92,6 +84,16 @@ export async function run(pathInput: string): Promise<void> {
|
|||||||
.update(JSON.stringify(manifest))
|
.update(JSON.stringify(manifest))
|
||||||
.digest('hex')
|
.digest('hex')
|
||||||
|
|
||||||
|
const response = await fetch(
|
||||||
|
process.env.GITHUB_API_URL + '/packages/container-registry-url'
|
||||||
|
)
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`Failed to fetch status page: ${response.statusText}`)
|
||||||
|
}
|
||||||
|
const data = await response.json()
|
||||||
|
const registryURL: URL = new URL(data.url)
|
||||||
|
console.log(`Container registry URL: ${registryURL}`)
|
||||||
|
|
||||||
const packageURL = await ghcr.publishOCIArtifact(
|
const packageURL = await ghcr.publishOCIArtifact(
|
||||||
token,
|
token,
|
||||||
registryURL,
|
registryURL,
|
||||||
|
|||||||
Reference in New Issue
Block a user