Compare commits
44 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5c1f7c551e | ||
|
|
cde9a1913a | ||
|
|
851300d465 | ||
|
|
39ba9c845f | ||
|
|
aa1e5622dd | ||
|
|
14d7a65708 | ||
|
|
93e94294df | ||
|
|
6e793d36ee | ||
|
|
f0cd0f993f | ||
|
|
cc1d3a4dbc | ||
|
|
a5f081bd53 | ||
|
|
32a88a3d14 | ||
|
|
10f13fc94d | ||
|
|
a7bc10bc0d | ||
|
|
53757c4d4e | ||
|
|
10115c380e | ||
|
|
9822365053 | ||
|
|
e1b6fb7a5d | ||
|
|
b162078db3 | ||
|
|
f7952001f5 | ||
|
|
a17c934fad | ||
|
|
8f88d958f5 | ||
|
|
5b199d021a | ||
|
|
54214a780d | ||
|
|
8c89fbd123 | ||
|
|
2b981e0eba | ||
|
|
436c132946 | ||
|
|
05dc7215e9 | ||
|
|
496a2134de | ||
|
|
d6c3a916ee | ||
|
|
ecd3566c81 | ||
|
|
f73439ca62 | ||
|
|
bf955761b2 | ||
|
|
98bf7786db | ||
|
|
42a7ee2bf3 | ||
|
|
3268a385e5 | ||
|
|
c0bf818478 | ||
|
|
61f4c9c927 | ||
|
|
7be9d34ace | ||
|
|
06c58cac8f | ||
|
|
15706adc71 | ||
|
|
0050aaf8ea | ||
|
|
4b20200534 | ||
|
|
c29f440249 |
@@ -1,7 +1,21 @@
|
|||||||
import {runCommand} from '../src/install'
|
import {install, runCommand} from '../src/install'
|
||||||
|
import * as core from '@actions/core'
|
||||||
|
|
||||||
import {expect, test} from '@jest/globals'
|
import {expect, test} from '@jest/globals'
|
||||||
|
|
||||||
test('runCommand', async () => {
|
test('runCommand', async () => {
|
||||||
const result = await runCommand('echo foo bar')
|
const result = await runCommand('echo foo bar')
|
||||||
expect(result).toBe('foo bar')
|
expect(result).toBe('foo bar')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
async function testVersion(version: string) {
|
||||||
|
const commandPath = await install(version)
|
||||||
|
core.addPath(commandPath)
|
||||||
|
const result = await runCommand('docker-compose version')
|
||||||
|
expect(result).toContain(version)
|
||||||
|
}
|
||||||
|
|
||||||
|
test('Install the right version', async () => {
|
||||||
|
await testVersion('1.29.1')
|
||||||
|
await testVersion('1.29.2')
|
||||||
|
})
|
||||||
|
|||||||
173
dist/index.js
vendored
173
dist/index.js
vendored
@@ -22,7 +22,7 @@ const exec_1 = __nccwpck_require__(514);
|
|||||||
function runCommand(command) {
|
function runCommand(command) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let output = '';
|
let output = '';
|
||||||
const result = yield exec_1.exec(command, [], {
|
const result = yield (0, exec_1.exec)(command, [], {
|
||||||
listeners: {
|
listeners: {
|
||||||
stdout: (data) => {
|
stdout: (data) => {
|
||||||
output += data.toString();
|
output += data.toString();
|
||||||
@@ -41,9 +41,10 @@ function installOnLinux(version) {
|
|||||||
const system = runCommand('uname -s');
|
const system = runCommand('uname -s');
|
||||||
const hardware = runCommand('uname -m');
|
const hardware = runCommand('uname -m');
|
||||||
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${yield system}-${yield hardware}`;
|
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${yield system}-${yield hardware}`;
|
||||||
const installerPath = yield tool_cache_1.downloadTool(url);
|
const installerPath = yield (0, tool_cache_1.downloadTool)(url);
|
||||||
yield exec_1.exec(`chmod +x ${installerPath}`);
|
yield (0, exec_1.exec)(`chmod +x ${installerPath}`);
|
||||||
return installerPath;
|
const cachedPath = yield (0, tool_cache_1.cacheFile)(installerPath, 'docker-compose', 'docker-compose', version);
|
||||||
|
return cachedPath;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
function install(version) {
|
function install(version) {
|
||||||
@@ -103,11 +104,11 @@ function run() {
|
|||||||
const version = core.getInput('version', {
|
const version = core.getInput('version', {
|
||||||
required: true
|
required: true
|
||||||
});
|
});
|
||||||
const commandPath = yield install_1.install(version);
|
const commandPath = yield (0, install_1.install)(version);
|
||||||
core.addPath(commandPath);
|
core.addPath(commandPath);
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
core.setFailed(error.message);
|
core.setFailed(error instanceof Error ? error.message : 'Unknown error');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -249,12 +250,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
|
exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
|
||||||
const command_1 = __nccwpck_require__(351);
|
const command_1 = __nccwpck_require__(351);
|
||||||
const file_command_1 = __nccwpck_require__(717);
|
const file_command_1 = __nccwpck_require__(717);
|
||||||
const utils_1 = __nccwpck_require__(278);
|
const utils_1 = __nccwpck_require__(278);
|
||||||
const os = __importStar(__nccwpck_require__(87));
|
const os = __importStar(__nccwpck_require__(87));
|
||||||
const path = __importStar(__nccwpck_require__(622));
|
const path = __importStar(__nccwpck_require__(622));
|
||||||
|
const oidc_utils_1 = __nccwpck_require__(41);
|
||||||
/**
|
/**
|
||||||
* The code to exit an action
|
* The code to exit an action
|
||||||
*/
|
*/
|
||||||
@@ -523,6 +525,12 @@ function getState(name) {
|
|||||||
return process.env[`STATE_${name}`] || '';
|
return process.env[`STATE_${name}`] || '';
|
||||||
}
|
}
|
||||||
exports.getState = getState;
|
exports.getState = getState;
|
||||||
|
function getIDToken(aud) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
return yield oidc_utils_1.OidcClient.getIDToken(aud);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
exports.getIDToken = getIDToken;
|
||||||
//# sourceMappingURL=core.js.map
|
//# sourceMappingURL=core.js.map
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
@@ -576,6 +584,90 @@ exports.issueCommand = issueCommand;
|
|||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 41:
|
||||||
|
/***/ (function(__unused_webpack_module, exports, __nccwpck_require__) {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||||
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||||
|
return new (P || (P = Promise))(function (resolve, reject) {
|
||||||
|
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||||
|
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||||
|
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||||
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
exports.OidcClient = void 0;
|
||||||
|
const http_client_1 = __nccwpck_require__(925);
|
||||||
|
const auth_1 = __nccwpck_require__(702);
|
||||||
|
const core_1 = __nccwpck_require__(186);
|
||||||
|
class OidcClient {
|
||||||
|
static createHttpClient(allowRetry = true, maxRetry = 10) {
|
||||||
|
const requestOptions = {
|
||||||
|
allowRetries: allowRetry,
|
||||||
|
maxRetries: maxRetry
|
||||||
|
};
|
||||||
|
return new http_client_1.HttpClient('actions/oidc-client', [new auth_1.BearerCredentialHandler(OidcClient.getRequestToken())], requestOptions);
|
||||||
|
}
|
||||||
|
static getRequestToken() {
|
||||||
|
const token = process.env['ACTIONS_ID_TOKEN_REQUEST_TOKEN'];
|
||||||
|
if (!token) {
|
||||||
|
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_TOKEN env variable');
|
||||||
|
}
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
static getIDTokenUrl() {
|
||||||
|
const runtimeUrl = process.env['ACTIONS_ID_TOKEN_REQUEST_URL'];
|
||||||
|
if (!runtimeUrl) {
|
||||||
|
throw new Error('Unable to get ACTIONS_ID_TOKEN_REQUEST_URL env variable');
|
||||||
|
}
|
||||||
|
return runtimeUrl;
|
||||||
|
}
|
||||||
|
static getCall(id_token_url) {
|
||||||
|
var _a;
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
const httpclient = OidcClient.createHttpClient();
|
||||||
|
const res = yield httpclient
|
||||||
|
.getJson(id_token_url)
|
||||||
|
.catch(error => {
|
||||||
|
throw new Error(`Failed to get ID Token. \n
|
||||||
|
Error Code : ${error.statusCode}\n
|
||||||
|
Error Message: ${error.result.message}`);
|
||||||
|
});
|
||||||
|
const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value;
|
||||||
|
if (!id_token) {
|
||||||
|
throw new Error('Response json body do not have ID Token field');
|
||||||
|
}
|
||||||
|
return id_token;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
static getIDToken(audience) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
try {
|
||||||
|
// New ID Token is requested from action service
|
||||||
|
let id_token_url = OidcClient.getIDTokenUrl();
|
||||||
|
if (audience) {
|
||||||
|
const encodedAudience = encodeURIComponent(audience);
|
||||||
|
id_token_url = `${id_token_url}&audience=${encodedAudience}`;
|
||||||
|
}
|
||||||
|
core_1.debug(`ID token url is ${id_token_url}`);
|
||||||
|
const id_token = yield OidcClient.getCall(id_token_url);
|
||||||
|
core_1.setSecret(id_token);
|
||||||
|
return id_token;
|
||||||
|
}
|
||||||
|
catch (error) {
|
||||||
|
throw new Error(`Error message: ${error.message}`);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.OidcClient = OidcClient;
|
||||||
|
//# sourceMappingURL=oidc-utils.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
/***/ 278:
|
/***/ 278:
|
||||||
/***/ ((__unused_webpack_module, exports) => {
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
@@ -611,6 +703,7 @@ function toCommandProperties(annotationProperties) {
|
|||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
title: annotationProperties.title,
|
title: annotationProperties.title,
|
||||||
|
file: annotationProperties.file,
|
||||||
line: annotationProperties.startLine,
|
line: annotationProperties.startLine,
|
||||||
endLine: annotationProperties.endLine,
|
endLine: annotationProperties.endLine,
|
||||||
col: annotationProperties.startColumn,
|
col: annotationProperties.startColumn,
|
||||||
@@ -1355,6 +1448,72 @@ class ExecState extends events.EventEmitter {
|
|||||||
}
|
}
|
||||||
//# sourceMappingURL=toolrunner.js.map
|
//# sourceMappingURL=toolrunner.js.map
|
||||||
|
|
||||||
|
/***/ }),
|
||||||
|
|
||||||
|
/***/ 702:
|
||||||
|
/***/ ((__unused_webpack_module, exports) => {
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||||
|
class BasicCredentialHandler {
|
||||||
|
constructor(username, password) {
|
||||||
|
this.username = username;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
prepareRequest(options) {
|
||||||
|
options.headers['Authorization'] =
|
||||||
|
'Basic ' +
|
||||||
|
Buffer.from(this.username + ':' + this.password).toString('base64');
|
||||||
|
}
|
||||||
|
// This handler cannot handle 401
|
||||||
|
canHandleAuthentication(response) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handleAuthentication(httpClient, requestInfo, objs) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.BasicCredentialHandler = BasicCredentialHandler;
|
||||||
|
class BearerCredentialHandler {
|
||||||
|
constructor(token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
// currently implements pre-authorization
|
||||||
|
// TODO: support preAuth = false where it hooks on 401
|
||||||
|
prepareRequest(options) {
|
||||||
|
options.headers['Authorization'] = 'Bearer ' + this.token;
|
||||||
|
}
|
||||||
|
// This handler cannot handle 401
|
||||||
|
canHandleAuthentication(response) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handleAuthentication(httpClient, requestInfo, objs) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.BearerCredentialHandler = BearerCredentialHandler;
|
||||||
|
class PersonalAccessTokenCredentialHandler {
|
||||||
|
constructor(token) {
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
// currently implements pre-authorization
|
||||||
|
// TODO: support preAuth = false where it hooks on 401
|
||||||
|
prepareRequest(options) {
|
||||||
|
options.headers['Authorization'] =
|
||||||
|
'Basic ' + Buffer.from('PAT:' + this.token).toString('base64');
|
||||||
|
}
|
||||||
|
// This handler cannot handle 401
|
||||||
|
canHandleAuthentication(response) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
handleAuthentication(httpClient, requestInfo, objs) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.PersonalAccessTokenCredentialHandler = PersonalAccessTokenCredentialHandler;
|
||||||
|
|
||||||
|
|
||||||
/***/ }),
|
/***/ }),
|
||||||
|
|
||||||
/***/ 925:
|
/***/ 925:
|
||||||
|
|||||||
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
2287
package-lock.json
generated
2287
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@kengotoda/actions-setup-docker-compose",
|
"name": "@kengotoda/actions-setup-docker-compose",
|
||||||
"version": "1.0.1",
|
"version": "1.0.3",
|
||||||
"description": "the GitHub Action setting up docker-compose command",
|
"description": "the GitHub Action setting up docker-compose command",
|
||||||
"main": "lib/main.js",
|
"main": "lib/main.js",
|
||||||
"private": false,
|
"private": false,
|
||||||
@@ -37,13 +37,13 @@
|
|||||||
"@semantic-release/git": "^9.0.0",
|
"@semantic-release/git": "^9.0.0",
|
||||||
"@types/node": "^16.3.2",
|
"@types/node": "^16.3.2",
|
||||||
"@typescript-eslint/parser": "^4.28.3",
|
"@typescript-eslint/parser": "^4.28.3",
|
||||||
"@vercel/ncc": "^0.29.0",
|
"@vercel/ncc": "^0.31.0",
|
||||||
"eslint": "^7.30.0",
|
"eslint": "^7.30.0",
|
||||||
"eslint-plugin-github": "^4.1.3",
|
"eslint-plugin-github": "^4.1.3",
|
||||||
"eslint-plugin-jest": "^24.3.6",
|
"eslint-plugin-jest": "^24.3.6",
|
||||||
"jest": "^27.0.6",
|
"jest": "^27.0.6",
|
||||||
"js-yaml": "^4.1.0",
|
"js-yaml": "^4.1.0",
|
||||||
"prettier": "2.3.2",
|
"prettier": "2.4.1",
|
||||||
"semantic-release": "^17.4.4",
|
"semantic-release": "^17.4.4",
|
||||||
"ts-jest": "^27.0.3",
|
"ts-jest": "^27.0.3",
|
||||||
"typescript": "^4.3.5"
|
"typescript": "^4.3.5"
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import {downloadTool} from '@actions/tool-cache'
|
import {cacheFile, downloadTool} from '@actions/tool-cache'
|
||||||
import {exec} from '@actions/exec'
|
import {exec} from '@actions/exec'
|
||||||
|
|
||||||
export async function runCommand(command: string): Promise<string> {
|
export async function runCommand(command: string): Promise<string> {
|
||||||
@@ -22,7 +22,13 @@ async function installOnLinux(version: string): Promise<string> {
|
|||||||
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${await system}-${await hardware}`
|
const url = `https://github.com/docker/compose/releases/download/${version}/docker-compose-${await system}-${await hardware}`
|
||||||
const installerPath = await downloadTool(url)
|
const installerPath = await downloadTool(url)
|
||||||
await exec(`chmod +x ${installerPath}`)
|
await exec(`chmod +x ${installerPath}`)
|
||||||
return installerPath
|
const cachedPath = await cacheFile(
|
||||||
|
installerPath,
|
||||||
|
'docker-compose',
|
||||||
|
'docker-compose',
|
||||||
|
version
|
||||||
|
)
|
||||||
|
return cachedPath
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function install(version: string): Promise<string> {
|
export async function install(version: string): Promise<string> {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ async function run(): Promise<void> {
|
|||||||
const commandPath = await install(version)
|
const commandPath = await install(version)
|
||||||
core.addPath(commandPath)
|
core.addPath(commandPath)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
core.setFailed(error.message)
|
core.setFailed(error instanceof Error ? error.message : 'Unknown error')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user