generated from actions/javascript-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (45 loc) · 1.57 KB
/
index.js
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
const core = require('@actions/core');
const {
CodeartifactClient,
GetAuthorizationTokenCommand,
GetRepositoryEndpointCommand,
// eslint-disable-next-line no-unused-vars
GetRepositoryEndpointCommandOutput,
PackageFormat,
} = require('@aws-sdk/client-codeartifact');
async function run() {
try {
const repository = core.getInput('domain');
const domain = core.getInput('domain');
const domainOwner = core.getInput('domain-owner');
const durationSeconds = core.getInput('duration-seconds');
const client = new CodeartifactClient({
region: 'eu-central-1',
});
const getRepositoryEndpointCmd = new GetRepositoryEndpointCommand({
domain,
domainOwner,
repository,
format: PackageFormat.PYPI,
});
/** @type GetRepositoryEndpointCommandOutput */
const endpointResult = await client.send(getRepositoryEndpointCmd);
core.exportVariable('CODEARTIFACT_ENDPOINT_PYPI', endpointResult.repositoryEndpoint);
core.info(`PyPi Repository Endpoint URL: ${endpointResult.repositoryEndpoint}`);
core.setOutput('endpoint-pypi', endpointResult.repositoryEndpoint);
const getAuthorizationTokenCmd = new GetAuthorizationTokenCommand({
domain,
domainOwner,
durationSeconds
});
const tokenResult = await client.send(getAuthorizationTokenCmd);
core.exportVariable('CODEARTIFACT_AUTH_TOKEN', tokenResult.authorizationToken);
core.setSecret(tokenResult.authorizationToken);
} catch (error) {
core.setFailed(error.message);
}
}
exports.run = run;
if (require.main === module) {
run();
}