Skip to content

Commit 9837515

Browse files
committed
Package code
1 parent ca9eddc commit 9837515

File tree

3 files changed

+43
-21
lines changed

3 files changed

+43
-21
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: 'GitHub Actions Variable Groups'
22
author: 'Brett Logan'
3-
description: 'Allows for the central management of environment variables across multiple GitHub Actions projects.'
3+
description: 'Allows for the central management of environment variables across multiple GitHub Actions workflows'
44
inputs:
55
groups:
66
description: A list of variable group files or directories containing variable group files.

dist/index.js

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14358,7 +14358,7 @@ const {retry} = __nccwpck_require__(6298);
1435814358
const {throttling} = __nccwpck_require__(9968);
1435914359
const _Octokit = Octokit.plugin(retry, throttling);
1436014360

14361-
const groups = core.getInput('groups', {required: true, trimWhitespace: true}).split('\n');
14361+
const groups = core.getInput('groups', {required: true, trimWhitespace: true}).split('\n').map(group => group.trim());
1436214362
const org = core.getInput('org', {required: true, trimWhitespace: true});
1436314363
const repo = core.getInput('repo', {required: true, trimWhitespace: true});
1436414364
const token = core.getInput('token', {required: true, trimWhitespace: true});
@@ -14381,9 +14381,13 @@ const client = new _Octokit({
1438114381

1438214382
(async function main() {
1438314383
try {
14384-
for (const group of groups) {
14384+
for (let group of groups) {
1438514385
core.info(`Processing group ${group}`)
14386-
const files = await retrieveFiles(group)
14386+
let ref
14387+
if (group.includes('@')) {
14388+
[group, ref] = group.split('@')
14389+
}
14390+
const files = await retrieveFiles(group, ref)
1438714391
if (Array.isArray(files)) {
1438814392
for (const _file of files) {
1438914393
const file = await retrieveFile(_file.path)
@@ -14399,30 +14403,49 @@ const client = new _Octokit({
1439914403
}
1440014404
})()
1440114405

14402-
async function retrieveFiles(group) {
14406+
async function retrieveFiles(group, ref) {
1440314407
try {
1440414408
core.info(`Retrieving files for group ${group}`)
14405-
const {data: files} = await client.repos.getContent({
14406-
owner: org,
14407-
repo: repo,
14408-
path: group
14409-
})
14410-
return files
14409+
if (ref) {
14410+
const {data: files} = await client.repos.getContent({
14411+
owner: org,
14412+
repo: repo,
14413+
path: group,
14414+
})
14415+
return files
14416+
} else {
14417+
const {data: files} = await client.repos.getContent({
14418+
owner: org,
14419+
repo: repo,
14420+
path: group,
14421+
})
14422+
return files
14423+
}
1441114424
} catch (err) {
1441214425
core.setFailed(`Fail to retrieve files ${group}: ${err.message}`)
1441314426
process.exit(1)
1441414427
}
1441514428
}
1441614429

14417-
async function retrieveFile(path) {
14430+
async function retrieveFile(path, ref) {
1441814431
try {
1441914432
core.info(`Retrieving file ${path}`)
14420-
const {data: file} = await client.repos.getContent({
14421-
owner: org,
14422-
repo: repo,
14423-
path: path
14424-
})
14425-
return file.content
14433+
if (ref) {
14434+
const {data: file} = await client.repos.getContent({
14435+
owner: org,
14436+
repo: repo,
14437+
path: path,
14438+
ref: ref
14439+
})
14440+
return file.content
14441+
} else {
14442+
const {data: file} = await client.repos.getContent({
14443+
owner: org,
14444+
repo: repo,
14445+
path: path,
14446+
})
14447+
return file.content
14448+
}
1442614449
} catch (err) {
1442714450
core.setFailed(`Fail to retrieve file ${path}: ${err.message}`)
1442814451
process.exit(1)

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"name": "actions-variable-groups",
33
"version": "1.0.0",
4-
"description": "",
4+
"description": "Allows for the central management of environment variables across multiple GitHub Actions workflows",
55
"main": "index.js",
66
"scripts": {
77
"build": "./node_modules/.bin/ncc build index.js"
88
},
9-
"keywords": [],
10-
"author": "",
9+
"author": "Brett Logan",
1110
"license": "Apache-2.0",
1211
"dependencies": {
1312
"@actions/core": "^1.6.0",

0 commit comments

Comments
 (0)