-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcli.ts
More file actions
61 lines (59 loc) · 2.44 KB
/
Copy pathcli.ts
File metadata and controls
61 lines (59 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import { parseArgs } from "@std/cli/parse-args"
// Tested in environment.test.ts
export const processCommandLineArgs = (cmdArgs: string[]) => {
const args = parseArgs(cmdArgs, {
string: [
"github_token",
"git_config",
"simulated_merge_type",
"output_file",
"make_pull_request_comment",
"fail_on_deploy_verification",
"debug",
"branch_filters",
"commit_limit",
"pull_request_comment_template_file",
"pull_request_comment_template",
"current_working_directory",
],
// collect: allows repeatable flags (e.g., --deploy staging --deploy prod) -> returns array
collect: [
"deploy",
"get_latest_release_current_branch",
"get_next_release_version",
],
default: {
github_token: "",
git_config: "github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>",
deploy: [],
get_latest_release_current_branch: [],
get_next_release_version: [],
simulated_merge_type: "",
output_file: "",
make_pull_request_comment: "true",
fail_on_deploy_verification: "true",
debug: "false",
branch_filters: "",
commit_limit: "",
pull_request_comment_template_file: "",
pull_request_comment_template: "",
current_working_directory: "",
},
})
// Inject CLI args into environment variables for downstream code
Deno.env.set("INPUT_GITHUB_TOKEN", args.github_token)
Deno.env.set("INPUT_GIT_CONFIG", args.git_config)
Deno.env.set("INPUT_DEPLOY", args.deploy.join("\n"))
Deno.env.set("INPUT_GET_LATEST_RELEASE_CURRENT_BRANCH", args.get_latest_release_current_branch.join("\n"))
Deno.env.set("INPUT_GET_NEXT_RELEASE_VERSION", args.get_next_release_version.join("\n"))
Deno.env.set("INPUT_SIMULATED_MERGE_TYPE", args.simulated_merge_type)
Deno.env.set("INPUT_OUTPUT_FILE", args.output_file)
Deno.env.set("INPUT_MAKE_PULL_REQUEST_COMMENT", args.make_pull_request_comment)
Deno.env.set("INPUT_FAIL_ON_DEPLOY_VERIFICATION", args.fail_on_deploy_verification)
Deno.env.set("INPUT_DEBUG", args.debug)
Deno.env.set("INPUT_BRANCH_FILTERS", args.branch_filters)
Deno.env.set("INPUT_COMMIT_LIMIT", args.commit_limit)
Deno.env.set("INPUT_PULL_REQUEST_COMMENT_TEMPLATE_FILE", args.pull_request_comment_template_file)
Deno.env.set("INPUT_PULL_REQUEST_COMMENT_TEMPLATE", args.pull_request_comment_template)
Deno.env.set("INPUT_CURRENT_WORKING_DIRECTORY", args.current_working_directory)
}