Skip to content

Commit 2e5cb18

Browse files
committed
add js for setup
1 parent b34852b commit 2e5cb18

File tree

3 files changed

+56
-20
lines changed

3 files changed

+56
-20
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"homepage": "https://github.com/fullstack-devops/awesome-ci-action#readme",
2323
"dependencies": {
2424
"@actions/core": "^1.6.0",
25+
"@actions/tool-cache": "^1.7.1",
2526
"fs": "^0.0.1-security",
2627
"http": "^0.0.1-security"
2728
},

src/main.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,37 @@
1+
import * as tc from '@actions/tool-cache';
12
import * as core from '@actions/core';
3+
import * as path from 'path';
24
import * as https from 'https';
35
import * as fs from 'fs';
46

5-
function run() {
7+
async function run() {
68
const wantedVersion = core.getInput('version');
79
const wantedArch = core.getInput('arch');
8-
10+
911
const actionsPath = process.env.GITHUB_ACTION_PATH
10-
const awesomeCiName = actionsPath+"/awesome-ci"
11-
12+
const awesomeCiName = actionsPath + "/awesome-ci"
13+
1214
// Download awesome-ci
1315
const repo = "fullstack-devops/awesome-ci"
1416
const downloadUrl = `https://github.com/${repo}/releases/download/${wantedVersion}/awesome-ci_${wantedVersion}_${wantedArch}`
1517
const file = fs.createWriteStream(awesomeCiName);
16-
17-
https.get(downloadUrl, (res) => {
18-
res.pipe(file)
19-
}).on('error', (e) => {
20-
core.setFailed("could not download awesome-ci: "+e)
21-
});
22-
23-
// add awesome-ci to path
24-
core.addPath(awesomeCiName);
25-
fs.chmod(awesomeCiName, 0o775, (err) => {
26-
if (err) throw core.error(err);
27-
core.info('The permissions for file "my_file.txt" have been changed!');
28-
});
18+
19+
20+
// core.info(`Acquiring ${info.resolvedVersion} from ${info.downloadUrl}`);
21+
const downloadPath = await tc.downloadTool(downloadUrl, undefined);
22+
23+
const extPath = path.join(downloadPath, 'awesome-ci');
24+
25+
26+
core.info('Adding to the cache ...');
27+
const cachedDir = await tc.cacheDir(
28+
extPath,
29+
'awesome-ci',
30+
wantedVersion
31+
);
32+
core.info(`Successfully cached awesome-ci to ${cachedDir}`);
2933
}
3034

35+
36+
3137
run();

yarn.lock

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,44 @@
22
# yarn lockfile v1
33

44

5-
"@actions/core@^1.6.0":
5+
"@actions/core@^1.2.6", "@actions/core@^1.6.0":
66
version "1.6.0"
77
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.6.0.tgz#0568e47039bfb6a9170393a73f3b7eb3b22462cb"
88
integrity sha512-NB1UAZomZlCV/LmJqkLhNTqtKfFXJZAUPcfl/zqG7EfsQdeUJtaWO98SGbuQ3pydJ3fHl2CvI/51OKYlCYYcaw==
99
dependencies:
1010
"@actions/http-client" "^1.0.11"
1111

12-
"@actions/http-client@^1.0.11":
12+
"@actions/exec@^1.0.0":
13+
version "1.1.0"
14+
resolved "https://registry.yarnpkg.com/@actions/exec/-/exec-1.1.0.tgz#53441d968e56d2fec69ad3f15773d4d94e01162c"
15+
integrity sha512-LImpN9AY0J1R1mEYJjVJfSZWU4zYOlEcwSTgPve1rFQqK5AwrEs6uWW5Rv70gbDIQIAUwI86z6B+9mPK4w9Sbg==
16+
dependencies:
17+
"@actions/io" "^1.0.1"
18+
19+
"@actions/http-client@^1.0.11", "@actions/http-client@^1.0.8":
1320
version "1.0.11"
1421
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-1.0.11.tgz#c58b12e9aa8b159ee39e7dd6cbd0e91d905633c0"
1522
integrity sha512-VRYHGQV1rqnROJqdMvGUbY/Kn8vriQe/F9HR2AlYHzmKuM/p3kjNuXhmdBfcVgsvRWTz5C5XW5xvndZrVBuAYg==
1623
dependencies:
1724
tunnel "0.0.6"
1825

26+
"@actions/io@^1.0.1", "@actions/io@^1.1.1":
27+
version "1.1.1"
28+
resolved "https://registry.yarnpkg.com/@actions/io/-/io-1.1.1.tgz#4a157406309e212ab27ed3ae30e8c1d641686a66"
29+
integrity sha512-Qi4JoKXjmE0O67wAOH6y0n26QXhMKMFo7GD/4IXNVcrtLjUlGjGuVys6pQgwF3ArfGTQu0XpqaNr0YhED2RaRA==
30+
31+
"@actions/tool-cache@^1.7.1":
32+
version "1.7.1"
33+
resolved "https://registry.yarnpkg.com/@actions/tool-cache/-/tool-cache-1.7.1.tgz#f9f4f822cb639da6facdf3e22ea571361ab26f92"
34+
integrity sha512-y1xxxOhXaBUIUit3lhepmu/0xdgiTMpnZRLmVdtF0hTm521doi+MdRRRP62czHvM7wxH6epj4JPNJQ3iJpOrkQ==
35+
dependencies:
36+
"@actions/core" "^1.2.6"
37+
"@actions/exec" "^1.0.0"
38+
"@actions/http-client" "^1.0.8"
39+
"@actions/io" "^1.1.1"
40+
semver "^6.1.0"
41+
uuid "^3.3.2"
42+
1943
"@babel/code-frame@^7.12.13", "@babel/code-frame@^7.16.7":
2044
version "7.16.7"
2145
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.16.7.tgz#44416b6bd7624b998f5b1af5d470856c40138789"
@@ -2354,7 +2378,7 @@ semver@^5.5.0:
23542378
resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7"
23552379
integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==
23562380

2357-
semver@^6.0.0, semver@^6.3.0:
2381+
semver@^6.0.0, semver@^6.1.0, semver@^6.3.0:
23582382
version "6.3.0"
23592383
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d"
23602384
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==
@@ -2611,6 +2635,11 @@ universalify@^0.1.2:
26112635
resolved "https://registry.yarnpkg.com/universalify/-/universalify-0.1.2.tgz#b646f69be3942dabcecc9d6639c80dc105efaa66"
26122636
integrity sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==
26132637

2638+
uuid@^3.3.2:
2639+
version "3.4.0"
2640+
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.4.0.tgz#b23e4358afa8a202fe7a100af1f5f883f02007ee"
2641+
integrity sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==
2642+
26142643
v8-to-istanbul@^8.1.0:
26152644
version "8.1.1"
26162645
resolved "https://registry.yarnpkg.com/v8-to-istanbul/-/v8-to-istanbul-8.1.1.tgz#77b752fd3975e31bbcef938f85e9bd1c7a8d60ed"

0 commit comments

Comments
 (0)