Skip to content

Commit

Permalink
Merge pull request #112 from mheap/reviewdog
Browse files Browse the repository at this point in the history
Make Reviewdog URL an input
  • Loading branch information
jdkato authored Jan 2, 2024
2 parents c99f2df + 35f7ebb commit 3f7188c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ inputs:
required: false
default: ""

reviewdog_url:
description: "The URL to a tar.gz build of reviewdog to use in the action"
required: false
default: ""

token:
description: "The GitHub token to use."
required: false
Expand Down
2 changes: 1 addition & 1 deletion lib/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function get(tok, dir) {
yield exec.exec('gem', ['install', 'asciidoctor', '--user-install']);
logIfDebug('`gem install asciidoctor --user-install` complete');
const localVale = yield (0, install_1.installLint)(core.getInput('version'));
const localReviewDog = yield (0, install_1.installReviewDog)("0.15.0");
const localReviewDog = yield (0, install_1.installReviewDog)("0.15.0", core.getInput('reviewdog_url'));
const valeFlags = core.getInput("vale_flags");
let version = '';
yield exec.exec(localVale, ['-v'], {
Expand Down
8 changes: 5 additions & 3 deletions lib/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,12 @@ function installLint(version) {
});
}
exports.installLint = installLint;
function installReviewDog(version) {
function installReviewDog(version, url) {
return __awaiter(this, void 0, void 0, function* () {
core.info(`Installing ReviewDog version '${version}' ...`);
const url = `https://github.com/reviewdog/reviewdog/releases/download/v${version}/reviewdog_${version}_Linux_x86_64.tar.gz`;
if (!url) {
url = `https://github.com/reviewdog/reviewdog/releases/download/v${version}/reviewdog_${version}_Linux_x86_64.tar.gz`;
}
const archivePath = yield tc.downloadTool(url);
let extractedDir = '';
const args = ['xz'];
Expand All @@ -77,7 +79,7 @@ function installReviewDog(version) {
}
extractedDir = yield tc.extractTar(archivePath, process.env.HOME, args);
const reviewdogPath = path_1.default.join(extractedDir, `reviewdog`);
core.info(`Installed version '${version}' into '${reviewdogPath}'.`);
core.info(`Installed reviewdog from '${url}' into '${reviewdogPath}'.`);
return reviewdogPath;
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export async function get(tok: string, dir: string): Promise<Input> {
logIfDebug('`gem install asciidoctor --user-install` complete');

const localVale = await installLint(core.getInput('version'));
const localReviewDog = await installReviewDog("0.15.0");
const localReviewDog = await installReviewDog("0.15.0", core.getInput('reviewdog_url'));
const valeFlags = core.getInput("vale_flags");

let version = '';
Expand Down
9 changes: 6 additions & 3 deletions src/install.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,13 @@ export async function installLint(version: string): Promise<string> {
return lintPath;
}

export async function installReviewDog(version: string): Promise<string> {
export async function installReviewDog(version: string, url?: string): Promise<string> {
core.info(`Installing ReviewDog version '${version}' ...`);

const url = `https://github.com/reviewdog/reviewdog/releases/download/v${version}/reviewdog_${version}_Linux_x86_64.tar.gz`;
if (!url){
url = `https://github.com/reviewdog/reviewdog/releases/download/v${version}/reviewdog_${version}_Linux_x86_64.tar.gz`;
}

const archivePath = await tc.downloadTool(url);

let extractedDir = '';
Expand All @@ -47,7 +50,7 @@ export async function installReviewDog(version: string): Promise<string> {
extractedDir = await tc.extractTar(archivePath, process.env.HOME, args);

const reviewdogPath = path.join(extractedDir, `reviewdog`);
core.info(`Installed version '${version}' into '${reviewdogPath}'.`);

core.info(`Installed reviewdog from '${url}' into '${reviewdogPath}'.`);
return reviewdogPath;
}

0 comments on commit 3f7188c

Please sign in to comment.