Skip to content

Commit 825b5a3

Browse files
committed
20221010B
1 parent dabfcf1 commit 825b5a3

File tree

17 files changed

+70
-72
lines changed

17 files changed

+70
-72
lines changed

hugoalh.GitHubActionsToolkit/module/environment-variable.psm1

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,7 @@ Function Add-PATH {
4747
}
4848
Switch -Exact ($ScopeArray) {
4949
'Current' {
50-
[System.Environment]::SetEnvironmentVariable('PATH', (
51-
([System.Environment]::GetEnvironmentVariable('PATH') -isplit [System.IO.Path]::PathSeparator) + $Item |
52-
Join-String -Separator [System.IO.Path]::PathSeparator
53-
)) |
54-
Out-Null
50+
Add-Content -LiteralPath $Env:PATH -Value "$([System.IO.Path]::PathSeparator)$Item" -Confirm:$False -NoNewLine
5551
}
5652
'Subsequent' {
5753
If ($Legacy) {

hugoalh.GitHubActionsToolkit/module/internal/token.psm1

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
11
#Requires -PSEdition Core
22
#Requires -Version 7.2
3-
[Char[]]$Pool = [String[]]@(0..9) + [Char[]]@(97..122)
3+
[Char[]]$PoolLowerCase = [Char[]]@(97..122)
4+
[Char[]]$PoolNumber = [String[]]@(0..9)
5+
[Char[]]$PoolUpperCase = [Char[]]@(65..90)
46
<#
57
.SYNOPSIS
68
GitHub Actions - Internal - New Random Token
79
.DESCRIPTION
8-
Get a new random token.
10+
Generate a new random token.
911
.PARAMETER Length
10-
Token length.
12+
Length of the token.
13+
.PARAMETER WithUpperCase
14+
Contain upper case letters in the token.
1115
.OUTPUTS
1216
[String] A new random token.
1317
#>
1418
Function New-RandomToken {
1519
[CmdletBinding()]
1620
[OutputType([String])]
1721
Param (
18-
[Parameter(Position = 0)][ValidateRange(1, [UInt32]::MaxValue)][UInt32]$Length = 8
22+
[Parameter(Position = 0)][ValidateRange(1, [UInt32]::MaxValue)][UInt32]$Length = 8,
23+
[Alias('UpperCase')][Switch]$WithUpperCase
1924
)
25+
[Char[]]$Pool = $PoolLowerCase + $PoolNumber + ($WithUpperCase.IsPresent ? $PoolUpperCase : @())
2026
@(1..$Length) |
2127
ForEach-Object -Process {
2228
$Pool |
Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,15 @@
1-
#!/usr/bin/env node
21
import { create as ghactionsArtifact } from "@actions/artifact";
3-
const input = JSON.parse(process.argv[2]);
4-
const result = await ghactionsArtifact().downloadAllArtifacts(input.Destination)
2+
const [inputs, delimiter] = process.argv.slice(2);
3+
const { Destination } = JSON.parse(inputs);
4+
const result = await ghactionsArtifact().downloadAllArtifacts(Destination)
55
.catch((reason) => {
66
console.error(reason);
77
return process.exit(1);
88
});
9-
console.log(process.argv[3]);
10-
let outputObject = [];
11-
for (let item of result) {
12-
outputObject.push({
13-
Name: item.artifactName,
14-
Path: item.downloadPath
15-
});
16-
}
17-
console.log(JSON.stringify(outputObject));
18-
process.exit(0);
9+
console.log(delimiter);
10+
console.log(JSON.stringify(result.map((value) => {
11+
return {
12+
Name: value.artifactName,
13+
Path: value.downloadPath
14+
};
15+
})));

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/artifact/download.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
1-
#!/usr/bin/env node
21
import { create as ghactionsArtifact } from "@actions/artifact";
3-
const input = JSON.parse(process.argv[2]);
4-
const result = await ghactionsArtifact().downloadArtifact(input.Name, input.Destination, { createArtifactFolder: input.CreateSubfolder })
2+
const [inputs, delimiter] = process.argv.slice(2);
3+
const {
4+
CreateSubfolder,
5+
Destination,
6+
Name
7+
} = JSON.parse(inputs);
8+
const result = await ghactionsArtifact().downloadArtifact(Name, Destination, { createArtifactFolder: CreateSubfolder })
59
.catch((reason) => {
610
console.error(reason);
711
return process.exit(1);
812
});
9-
console.log(process.argv[3]);
13+
console.log(delimiter);
1014
console.log(JSON.stringify({
1115
Name: result.artifactName,
1216
Path: result.downloadPath
1317
}));
14-
process.exit(0);

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/artifact/upload.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
#!/usr/bin/env node
21
import { create as ghactionsArtifact } from "@actions/artifact";
3-
const input = JSON.parse(process.argv[2]);
4-
const result = await ghactionsArtifact().uploadArtifact(input.Name, input.Path, input.BaseRoot, {
5-
continueOnError: input.ContinueOnIssue,
6-
retentionDays: input.RetentionTime
2+
const [inputs, delimiter] = process.argv.slice(2);
3+
const {
4+
BaseRoot,
5+
ContinueOnIssue,
6+
Name,
7+
Path,
8+
RetentionTime
9+
} = JSON.parse(inputs);
10+
const result = await ghactionsArtifact().uploadArtifact(Name, Path, BaseRoot, {
11+
continueOnError: ContinueOnIssue,
12+
retentionDays: RetentionTime
713
})
814
.catch((reason) => {
915
console.error(reason);
1016
return process.exit(1);
1117
});
12-
console.log(process.argv[3]);
18+
console.log(delimiter);
1319
console.log(JSON.stringify({
1420
FailedItem: result.failedItems,
1521
FailedItems: result.failedItems,
@@ -19,4 +25,3 @@ console.log(JSON.stringify({
1925
Size: result.size,
2026
Sizes: result.size
2127
}));
22-
process.exit(0);

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/cache/restore.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,21 @@
1-
#!/usr/bin/env node
21
import { restoreCache as ghactionsCacheRestoreCache } from "@actions/cache";
3-
const input = JSON.parse(process.argv[2]);
4-
const result = await ghactionsCacheRestoreCache(input.Path, input.PrimaryKey, input.RestoreKey, {
5-
downloadConcurrency: input.DownloadConcurrency,
6-
timeoutInMs: input.Timeout,
7-
useAzureSdk: input.UseAzureSdk
2+
const [inputs, delimiter] = process.argv.slice(2);
3+
const {
4+
DownloadConcurrency,
5+
Path,
6+
PrimaryKey,
7+
RestoreKey,
8+
Timeout,
9+
UseAzureSdk
10+
} = JSON.parse(inputs);
11+
const result = await ghactionsCacheRestoreCache(Path, PrimaryKey, RestoreKey, {
12+
downloadConcurrency: DownloadConcurrency,
13+
timeoutInMs: Timeout,
14+
useAzureSdk: UseAzureSdk
815
})
916
.catch((reason) => {
1017
console.error(reason);
1118
return process.exit(1);
1219
});
13-
console.log(process.argv[3]);
20+
console.log(delimiter);
1421
console.log(JSON.stringify({ CacheKey: result }));
15-
process.exit(0);

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/cache/save.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,18 @@
1-
#!/usr/bin/env node
21
import { saveCache as ghactionsCacheSaveCache } from "@actions/cache";
3-
const input = JSON.parse(process.argv[2]);
4-
const result = await ghactionsCacheSaveCache(input.Path, input.Key, {
5-
uploadChunkSize: input.UploadChunkSizes,
6-
uploadConcurrency: input.UploadConcurrency
2+
const [inputs, delimiter] = process.argv.slice(2);
3+
const {
4+
Key,
5+
Path,
6+
UploadChunkSizes,
7+
UploadConcurrency
8+
} = JSON.parse(inputs);
9+
const result = await ghactionsCacheSaveCache(Path, Key, {
10+
uploadChunkSize: UploadChunkSizes,
11+
uploadConcurrency: UploadConcurrency
712
})
813
.catch((reason) => {
914
console.error(reason);
1015
return process.exit(1);
1116
});
12-
console.log(process.argv[3]);
17+
console.log(delimiter);
1318
console.log(JSON.stringify({ CacheId: result }));
14-
process.exit(0);
Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
#!/usr/bin/env node
21
import { getIDToken as ghactionsGetOpenIDConnectToken } from "@actions/core";
3-
const input = JSON.parse(process.argv[2]);
4-
const result = await ghactionsGetOpenIDConnectToken(input.Audience)
2+
const [inputs, delimiter] = process.argv.slice(2);
3+
const { Audience } = JSON.parse(inputs);
4+
const result = await ghactionsGetOpenIDConnectToken(Audience)
55
.catch((reason) => {
66
console.error(reason);
77
return process.exit(1);
88
});
9-
console.log(process.argv[3]);
9+
console.log(delimiter);
1010
console.log(JSON.stringify({ Token: result }));
11-
process.exit(0);
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env node
21
import { cacheDir as ghactionsToolCacheCacheDirectory } from "@actions/tool-cache";
32
const input = JSON.parse(process.argv[2]);
43
const result = await ghactionsToolCacheCacheDirectory(input.Source, input.Name, input.Version, input.Architecture)
@@ -8,4 +7,3 @@ const result = await ghactionsToolCacheCacheDirectory(input.Source, input.Name,
87
});
98
console.log(process.argv[3]);
109
console.log(JSON.stringify({ Path: result }));
11-
process.exit(0);
Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#!/usr/bin/env node
21
import { cacheFile as ghactionsToolCacheCacheFile } from "@actions/tool-cache";
32
const input = JSON.parse(process.argv[2]);
43
const result = await ghactionsToolCacheCacheFile(input.Source, input.Target, input.Name, input.Version, input.Architecture)
@@ -8,4 +7,3 @@ const result = await ghactionsToolCacheCacheFile(input.Source, input.Target, inp
87
});
98
console.log(process.argv[3]);
109
console.log(JSON.stringify({ Path: result }));
11-
process.exit(0);

0 commit comments

Comments
 (0)