Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions install/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ inputs:
tool_versions:
description: If present, this value will be written to the .tool-versions file.
required: false
working_directory:
description: Directory containing the .tool-versions file. Defaults to repository root.
required: false
before_install:
description:
Bash script to run after plugins are installed but before `asdf install`.
Expand Down
176 changes: 91 additions & 85 deletions install/main.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions plugins-add/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ inputs:
tool_versions:
description: If present, this value will be written to the .tool-versions file.
required: false
working_directory:
description: Directory containing the .tool-versions file. Defaults to repository root.
required: false
github_token:
description: Token used to avoid rate limit when asdf calls the GitHub API
required: false
Expand Down
167 changes: 86 additions & 81 deletions plugins-add/main.js

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions src/install/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import * as core from "@actions/core";
import * as exec from "@actions/exec";
import { pluginsAdd } from "~/plugins-add/index.ts";

async function toolsInstall(): Promise<void> {
await pluginsAdd();
async function toolsInstall(workingDirectory?: string): Promise<void> {
await pluginsAdd(workingDirectory);

const execOptions = workingDirectory ? { cwd: workingDirectory } : undefined;
const before = core.getInput("before_install", { required: false });
if (before) {
await exec.exec("bash", ["-c", before]);
await exec.exec("bash", ["-c", before], execOptions);
}

await exec.exec("asdf", ["install"]);
await exec.exec("asdf", ["install"], execOptions);
}

export { toolsInstall };
5 changes: 4 additions & 1 deletion src/install/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { toolsInstall } from "~/install/index.ts";

(async () => {
try {
await toolsInstall();
const workingDirectory = core.getInput("working_directory", {
required: false,
});
await toolsInstall(workingDirectory || undefined);
} catch (error) {
core.setFailed(`Action failed with error ${error}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
}
Expand Down
8 changes: 5 additions & 3 deletions src/plugins-add/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type * as buffer from "node:buffer";
import * as fs from "node:fs";
import * as path from "node:path";
import * as core from "@actions/core";
import * as exec from "@actions/exec";
import { setupAsdf } from "~/setup/index.ts";
Expand Down Expand Up @@ -29,16 +30,17 @@ async function pluginList() {
return stdout.split("\n");
}

async function pluginsAdd(): Promise<void> {
async function pluginsAdd(workingDirectory?: string): Promise<void> {
await setupAsdf();
const toolVersionsPath = path.join(workingDirectory || ".", ".tool-versions");
let toolVersions = core.getInput("tool_versions", { required: false });

if (toolVersions) {
await fs.promises.writeFile(".tool-versions", toolVersions, {
await fs.promises.writeFile(toolVersionsPath, toolVersions, {
encoding: "utf8",
});
} else {
toolVersions = await fs.promises.readFile(".tool-versions", {
toolVersions = await fs.promises.readFile(toolVersionsPath, {
encoding: "utf8",
});
}
Expand Down
5 changes: 4 additions & 1 deletion src/plugins-add/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { pluginsAdd } from "~/plugins-add/index.ts";

(async () => {
try {
await pluginsAdd();
const workingDirectory = core.getInput("working_directory", {
required: false,
});
await pluginsAdd(workingDirectory || undefined);
} catch (error) {
core.setFailed(`Action failed with error ${error}`); // eslint-disable-line @typescript-eslint/restrict-template-expressions
}
Expand Down