Skip to content

Commit

Permalink
dist update
Browse files Browse the repository at this point in the history
  • Loading branch information
bitmaskit committed Jan 27, 2025
1 parent 55e3a38 commit 54d7617
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 8 deletions.
18 changes: 14 additions & 4 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ export async function downloadPiperBinary (
let binaryURL
const headers: any = {}
const piperBinaryName = await getPiperBinaryNameFromInputs(isEnterprise, version)
debug(`version: ${version}`)
if (token !== '') {
debug('Fetching binary from GitHub API')
headers.Accept = 'application/octet-stream'
headers.Authorization = `token ${token}`

const [binaryAssetURL, tag] = await getReleaseAssetUrl(piperBinaryName, version, apiURL, token, owner, repo)
debug(`downloadPiperBinary: binaryAssetURL: ${binaryAssetURL}, tag: ${tag}`)
binaryURL = binaryAssetURL
version = tag
} else {
Expand Down
15 changes: 12 additions & 3 deletions src/enterprise.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { GITHUB_COM_SERVER_URL, getReleaseAssetUrl } from './github'
import { debug } from '@actions/core'

export const DEFAULT_CONFIG = 'DefaultConfig'
export const STAGE_CONFIG = 'StageConfig'
Expand All @@ -20,21 +21,29 @@ export function onGitHubEnterprise (): boolean {
}

export async function getEnterpriseConfigUrl (configType: string, apiURL: string, version: string, token: string, owner: string, repository: string): Promise<string> {
debug('Getting enterprise config URL')
if (configType !== DEFAULT_CONFIG && configType !== STAGE_CONFIG) {
return ''
}

debug('initiating assetName and filename')
let assetName: string = ENTERPRISE_DEFAULTS_FILENAME_ON_RELEASE
let filename: string = ENTERPRISE_DEFAULTS_FILENAME

if (configType === STAGE_CONFIG) {
debug('configType is STAGE_CONFIG')
assetName = ENTERPRISE_STAGE_CONFIG_FILENAME
filename = ENTERPRISE_STAGE_CONFIG_FILENAME
}

debug('Getting enterprise config URL')
// get URL of defaults from the release (gh api, authenticated)
const [url] = await getReleaseAssetUrl(assetName, version, apiURL, token, owner, repository)
if (url !== '') return url
// fallback to get URL of defaults in the repository (unauthenticated)
return `${process.env.GITHUB_API_URL}/repos/${owner}/${repository}/contents/resources/${filename}`
if (url === '') {
// fallback to get URL of defaults in the repository (unauthenticated)
debug(`Fallback to get URL of defaults in the repository: ${process.env.GITHUB_API_URL}/repos/${owner}/${repository}/contents/resources/${filename}`)
return `${process.env.GITHUB_API_URL}/repos/${owner}/${repository}/contents/resources/${filename}`
}
debug(`Returning enterprise config URL ${url}`)
return url
}

0 comments on commit 54d7617

Please sign in to comment.