-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathaction.ts
More file actions
38 lines (34 loc) · 1.03 KB
/
action.ts
File metadata and controls
38 lines (34 loc) · 1.03 KB
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
import * as core from '@actions/core';
// https://help.github.com/en/actions/automating-your-workflow-with-github-actions/using-environment-variables#default-environment-variables
const env_vars = [
'GITHUB_WORKFLOW',
'GITHUB_ACTION',
'GITHUB_ACTIONS',
'GITHUB_ACTOR',
'GITHUB_REPOSITORY',
'GITHUB_EVENT_NAME',
'GITHUB_EVENT_PATH',
'GITHUB_WORKSPACE',
'GITHUB_SHA',
'GITHUB_REF',
'GITHUB_HEAD_REF',
'GITHUB_BASE_REF'
];
async function run(): Promise<void> {
try {
for (const env_var of env_vars) {
if (env_var in process.env && process.env[env_var] !== "") {
core.exportVariable(env_var, process.env[env_var])
}
}
// Also add USERPROFILE or HOME depending on platform
if (process.platform === 'win32') {
core.exportVariable('HOME', process.env.USERPROFILE)
} else {
core.exportVariable('HOME', process.env.HOME)
}
} catch (error) {
core.setFailed(error.message)
}
}
run()