Skip to content

Commit

Permalink
Add config option
Browse files Browse the repository at this point in the history
  • Loading branch information
hasufell committed Jan 2, 2025
1 parent 7a55b60 commit 6bc6a5c
Show file tree
Hide file tree
Showing 7 changed files with 206 additions and 50 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/test-ghcup.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ jobs:
with:
stack-hook: true
version: ${{ matrix.version }}
config: |
url-source:
- StackSetupURL
verbose: true
- run: ghcup config
- run: ghcup debug-info
Expand Down
6 changes: 4 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ inputs:
default: latest
release-channels:
description: Set the release-channels
default: |
GHCupURL
default: null
stack-hook:
description: Install the GHCup stack hook (GHCs are installed through ghcup)
default: false
config:
description: GHCup config (partial or full)
default: null

outputs:
path:
Expand Down
Binary file modified ghcup/bun.lockb
Binary file not shown.
218 changes: 178 additions & 40 deletions ghcup/dist/index.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion ghcup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@actions/core": "^1.11.1",
"@actions/exec": "^1.1.1",
"@actions/io": "^1.1.3",
"@actions/tool-cache": "^2.0.1"
"@actions/tool-cache": "^2.0.1",
"yaml": "^2.7.0"
}
}
4 changes: 4 additions & 0 deletions ghcup/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { main, getInputAsBool } from "./main.ts";
import core from "@actions/core";
import YAML from "yaml";

try {
main({
version: core.getInput("version"),
release_channels: core.getMultilineInput("release-channels"),
stack_hook: getInputAsBool("stack-hook"),
config:
YAML.parse(core.getInput("config")) ??
JSON.parse(core.getInput("config")),
});
} catch (error) {
core.setFailed((error as Error).message);
Expand Down
21 changes: 14 additions & 7 deletions ghcup/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,9 @@ export function getInputAsBool(

export type Opts = {
version: string;
release_channels: string[];
release_channels?: string[];
stack_hook: boolean;
config?: any;
};

export async function main(opts: Opts) {
Expand Down Expand Up @@ -173,10 +174,16 @@ export async function main(opts: Opts) {
installStackHook();
}

await exec.exec(ghcupPath, [
"config",
"set",
"url-source",
JSON.stringify(opts.release_channels),
]);
if (opts.config) {
await exec.exec(ghcupPath, ["config", "set", JSON.stringify(opts.config)]);
}

if (opts.release_channels && opts.release_channels.length > 0) {
await exec.exec(ghcupPath, [
"config",
"set",
"url-source",
JSON.stringify(opts.release_channels),
]);
}
}

0 comments on commit 6bc6a5c

Please sign in to comment.