-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.ts
More file actions
158 lines (149 loc) · 3.86 KB
/
github.ts
File metadata and controls
158 lines (149 loc) · 3.86 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/**
* @fileoverview GitHub Actions environment variable getters.
* Provides access to GitHub Actions CI/CD environment variables.
*/
import { getEnvValue } from './rewire'
/**
* GH_TOKEN environment variable.
* Alternative GitHub authentication token for API access (used by GitHub CLI).
*
* @returns The GH CLI token, or `undefined` if not set
*
* @example
* ```typescript
* import { getGhToken } from '@socketsecurity/lib/env/github'
*
* const token = getGhToken()
* // e.g. 'gho_abc123...' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getGhToken(): string | undefined {
return getEnvValue('GH_TOKEN')
}
/**
* GITHUB_API_URL environment variable.
* GitHub API URL (e.g., https://api.github.com).
*
* @returns The GitHub API URL, or `undefined` if not set
*
* @example
* ```typescript
* import { getGithubApiUrl } from '@socketsecurity/lib/env/github'
*
* const apiUrl = getGithubApiUrl()
* // e.g. 'https://api.github.com' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getGithubApiUrl(): string | undefined {
return getEnvValue('GITHUB_API_URL')
}
/**
* GITHUB_BASE_REF environment variable.
* GitHub pull request base branch.
*
* @returns The pull request base branch name, or `undefined` if not set
*
* @example
* ```typescript
* import { getGithubBaseRef } from '@socketsecurity/lib/env/github'
*
* const baseRef = getGithubBaseRef()
* // e.g. 'main' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getGithubBaseRef(): string | undefined {
return getEnvValue('GITHUB_BASE_REF')
}
/**
* GITHUB_REF_NAME environment variable.
* GitHub branch or tag name.
*
* @returns The branch or tag name, or `undefined` if not set
*
* @example
* ```typescript
* import { getGithubRefName } from '@socketsecurity/lib/env/github'
*
* const refName = getGithubRefName()
* // e.g. 'feature/my-branch' or 'v1.0.0'
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getGithubRefName(): string | undefined {
return getEnvValue('GITHUB_REF_NAME')
}
/**
* GITHUB_REF_TYPE environment variable.
* GitHub ref type (branch or tag).
*
* @returns The ref type ('branch' or 'tag'), or `undefined` if not set
*
* @example
* ```typescript
* import { getGithubRefType } from '@socketsecurity/lib/env/github'
*
* const refType = getGithubRefType()
* // e.g. 'branch' or 'tag'
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getGithubRefType(): string | undefined {
return getEnvValue('GITHUB_REF_TYPE')
}
/**
* GITHUB_REPOSITORY environment variable.
* GitHub repository name in owner/repo format.
*
* @returns The repository name, or `undefined` if not set
*
* @example
* ```typescript
* import { getGithubRepository } from '@socketsecurity/lib/env/github'
*
* const repo = getGithubRepository()
* // e.g. 'SocketDev/socket-cli' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getGithubRepository(): string | undefined {
return getEnvValue('GITHUB_REPOSITORY')
}
/**
* GITHUB_SERVER_URL environment variable.
* GitHub server URL (e.g., https://github.com).
*
* @returns The GitHub server URL, or `undefined` if not set
*
* @example
* ```typescript
* import { getGithubServerUrl } from '@socketsecurity/lib/env/github'
*
* const serverUrl = getGithubServerUrl()
* // e.g. 'https://github.com' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getGithubServerUrl(): string | undefined {
return getEnvValue('GITHUB_SERVER_URL')
}
/**
* GITHUB_TOKEN environment variable.
* GitHub authentication token for API access.
*
* @returns The GitHub token, or `undefined` if not set
*
* @example
* ```typescript
* import { getGithubToken } from '@socketsecurity/lib/env/github'
*
* const token = getGithubToken()
* // e.g. 'ghp_abc123...' or undefined
* ```
*/
/*@__NO_SIDE_EFFECTS__*/
export function getGithubToken(): string | undefined {
return getEnvValue('GITHUB_TOKEN')
}