-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
43 lines (35 loc) · 1.22 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
const core = require('@actions/core');
const github = require('@actions/github');
const { Octokit } = require('@octokit/core');
async function run() {
try {
const token = process.env.GITHUB_TOKEN;
if (!token) {
throw new Error('GITHUB_TOKEN is not set');
}
const environmentName = core.getInput('environment_name');
if (!environmentName) {
throw new Error('Environment name is not set or is empty');
}
const owner = core.getInput('owner') || github.context.repo.owner;
const repo = core.getInput('repo') || github.context.repo.repo;
const octokit = new Octokit({
auth: token
});
console.log(`Requesting secrets for environment: ${environmentName} in repo: ${owner}/${repo}`);
const response = await octokit.request('GET /repos/{owner}/{repo}/environments/{environment_name}/secrets', {
owner,
repo,
environment_name: environmentName,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
});
console.log('Secrets:', response.data.secrets);
} catch (error) {
console.error(`Error: ${error.message}`);
console.error(`Stack: ${error.stack}`);
core.setFailed(`Action failed with error: ${error.message}`);
}
}
run();