-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add support for artifactory auth #48
Changes from 6 commits
0766e15
cdf0071
6c27450
5cc7243
fabf091
8389e57
28524c2
e7f5bf6
bd16dba
8931743
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import { addPath } from "@actions/core"; | ||
import { exec } from "@actions/exec"; | ||
import { GitHub } from "@actions/github"; | ||
import {addPath} from "@actions/core"; | ||
import {exec} from "@actions/exec"; | ||
import {GitHub} from "@actions/github"; | ||
import semver from "semver"; | ||
import os from "os"; | ||
|
||
|
@@ -84,6 +84,10 @@ async function authenticate(token: string): Promise<void> { | |
await exec("foreman", ["github-auth", token]); | ||
} | ||
|
||
async function addArtifactoryToken(url: string, token: string): Promise<void> { | ||
await exec("foreman", ["artifactory-auth", url, token]); | ||
} | ||
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. Oh, do we need to check the version before we can do this? Or can we just count on the error carrying through and hope that folks can figure it out? 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. hmmm, we should probably warn if the version selected is below the supported version |
||
|
||
function addBinDirToPath(): void { | ||
if (process.platform === "win32") { | ||
addPath(`${process.env.USERPROFILE}\\.foreman\\bin`); | ||
|
@@ -105,7 +109,8 @@ export default { | |
authenticate, | ||
addBinDirToPath, | ||
installTools, | ||
filterValidReleases | ||
filterValidReleases, | ||
addArtifactoryToken | ||
}; | ||
|
||
export type { GitHubRelease }; | ||
export type {GitHubRelease}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
import { getInput, debug, addPath, setFailed } from "@actions/core"; | ||
import { downloadTool, extractZip } from "@actions/tool-cache"; | ||
import { GitHub } from "@actions/github"; | ||
import { resolve } from "path"; | ||
import { exec } from "@actions/exec"; | ||
import {getInput, debug, addPath, setFailed} from "@actions/core"; | ||
import {downloadTool, extractZip} from "@actions/tool-cache"; | ||
import {GitHub} from "@actions/github"; | ||
import {resolve} from "path"; | ||
import {exec} from "@actions/exec"; | ||
import configFile from "./configFile"; | ||
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. Nitpick, but any idea why this formatting is changing? I thought the convention was to have the spaces. 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. hmmm, my local set up might have a different formatter set up. Ill revert this |
||
import foreman from "./foreman"; | ||
|
||
|
@@ -15,6 +15,8 @@ async function run(): Promise<void> { | |
const allowExternalGithubOrgs: string = getInput( | ||
"allow-external-github-orgs" | ||
).toLowerCase(); | ||
const artifactoryUrl = getInput("artifactory-url"); | ||
const artifactoryToken = getInput("artifactory-token"); | ||
|
||
const octokit = new GitHub(githubToken, { | ||
baseUrl: githubApiUrl | ||
|
@@ -50,6 +52,15 @@ async function run(): Promise<void> { | |
} | ||
|
||
await foreman.authenticate(githubToken); | ||
|
||
if (artifactoryUrl != "" && artifactoryToken != "") { // both defined | ||
await foreman.addArtifactoryToken(artifactoryUrl, artifactoryToken); | ||
} else if (artifactoryUrl != "" || artifactoryToken != "") { // only one defined | ||
throw new Error( | ||
"Both artifactory-url and artifactory-token must be set or null" | ||
); | ||
} | ||
|
||
foreman.addBinDirToPath(); | ||
|
||
if (workingDir !== undefined && workingDir !== null && workingDir !== "") { | ||
|
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.
Wait, why was this missing? Does this
action.yml
file actually get used?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.
I think
action.yml
is used to give information about how the action is used, so it would warn that an unknown argument was used whenallow-external-github-org
was set. AFAIK, it doesn't affect any functionality