Skip to content

Commit 68e49ea

Browse files
authored
add the workspace env variable
1 parent 2e3536e commit 68e49ea

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ inputs:
88
config:
99
required: true
1010
description: 'Path to the config'
11+
workspace:
12+
required: false
13+
description: 'Path to the root of the workspace'
1114
runs:
1215
using: 'node12'
1316
main: 'dist/index.js'

src/config.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
import { Schema, Validator } from 'jsonschema';
22
import * as path from 'path';
33

4+
import * as core from '@actions/core';
5+
46
import { PROJECT_ROOT } from './constants';
57

68
import { IConfig } from './interfaces/IConfig';
79

10+
const getWorkspacePath = (configFilePath: string) => {
11+
const rootPath = core.getInput('workspace');
12+
if (!rootPath) {
13+
return;
14+
}
15+
16+
return path.join(rootPath, configFilePath);
17+
}
18+
819
export const getConfigs = (configFilePath: string): IConfig[] => {
9-
const configs = require(path.join(PROJECT_ROOT, configFilePath));
20+
const rootPath = getWorkspacePath(configFilePath) ?? path.join(PROJECT_ROOT, configFilePath);
21+
const configs = require(rootPath);
1022

1123
return configs;
1224
};

src/main.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import * as core from '@actions/core';
2-
import { Validator } from 'jsonschema';
32

43
// add .env file support for dev purposes
54
require('dotenv').config();
65

76
import { AuthorizationError } from './errors/AuthorizationError';
87
import { ProjectsOctoKit } from './octokit/ProjectsOctoKit';
98
import { renderProject } from './views/renderProject';
10-
import { renderOverview } from './views/renderOverview';
119
import { getProjectData } from './utils/getProjectData';
1210
import { env } from './utils/env';
1311
import { getConfigs, validateConfig } from './config';

0 commit comments

Comments
 (0)