Skip to content

Commit

Permalink
Fix working dir (#241)
Browse files Browse the repository at this point in the history
Co-authored-by: CrazyMax <crazy-max@users.noreply.github.com>
  • Loading branch information
crazy-max and crazy-max committed Dec 19, 2021
1 parent f75e4f1 commit 6369b8f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 22 deletions.
1 change: 0 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ inputs:
required: false
workdir:
description: 'Working directory (below repository root)'
default: '.'
required: false

runs:
Expand Down
18 changes: 8 additions & 10 deletions dist/index.js

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

6 changes: 3 additions & 3 deletions src/installer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ export async function getMage(version: string): Promise<string> {
}
const semver: string = release.tag_name.replace(/^v/, '');

core.info(`Mage version found: ${release.tag_name}`);
core.info(`Mage version found: ${release.tag_name}`);
const filename: string = getFilename(semver);
const downloadUrl: string = util.format(
'https://github.com/magefile/mage/releases/download/%s/%s',
release.tag_name,
filename
);

core.info(`⬇️ Downloading ${downloadUrl}...`);
core.info(`Downloading ${downloadUrl}...`);
const downloadPath: string = await tc.downloadTool(downloadUrl);
core.debug(`Downloaded to ${downloadPath}`);

core.info('📦 Extracting Mage...');
core.info('Extracting Mage...');
let extPath: string;
if (osPlat == 'win32') {
extPath = await tc.extractZip(downloadPath);
Expand Down
13 changes: 5 additions & 8 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,13 @@ async function run(): Promise<void> {
try {
const version = core.getInput('version') || 'latest';
const args = core.getInput('args');
const workdir = core.getInput('workdir') || '.';
const workdir = core.getInput('workdir') || process.env['GITHUB_WORKSPACE'] || '.';
const mage = await installer.getMage(version);

if (workdir && workdir !== '.') {
core.info(`📂 Using ${workdir} as working directory...`);
process.chdir(workdir);
}

core.info('🏃 Running Mage...');
await exec.exec(`${mage} ${args}`);
core.info('Running Mage...');
await exec.exec(`${mage} ${args}`, undefined, {
cwd: workdir
});
} catch (error) {
core.setFailed(error.message);
}
Expand Down

0 comments on commit 6369b8f

Please sign in to comment.