|
6 | 6 | startGroup, |
7 | 7 | endGroup |
8 | 8 | } from '@actions/core' |
9 | | -import axios from 'axios' |
10 | 9 | import path from 'path' |
11 | 10 | import simpleGit, { Response } from 'simple-git' |
12 | 11 | import YAML from 'js-yaml' |
@@ -179,25 +178,10 @@ async function checkInputs() { |
179 | 178 | const eventPath = process.env.GITHUB_EVENT_PATH, |
180 | 179 | event = eventPath && require(eventPath), |
181 | 180 | isPR = process.env.GITHUB_EVENT_NAME?.includes('pull_request'), |
182 | | - sha = (event?.pull_request?.head?.sha || process.env.GITHUB_SHA) as string, |
183 | 181 | defaultBranch = isPR |
184 | 182 | ? (event?.pull_request?.head?.ref as string) |
185 | 183 | : process.env.GITHUB_REF?.substring(11) |
186 | 184 |
|
187 | | - // #region GITHUB_TOKEN |
188 | | - let token = process.env.GITHUB_TOKEN |
189 | | - if (token) { |
190 | | - debug('Using token from GITHUB_TOKEN env variable.') |
191 | | - warning( |
192 | | - "The GITHUB_TOKEN env variable is deprecated and will not be supported in the next major release. Use the 'token' input, " + |
193 | | - "which defaults to 'secrets.GITHUB_TOKEN'." |
194 | | - ) |
195 | | - } else { |
196 | | - debug('Using token from token input.') |
197 | | - token = getInput('token') |
198 | | - } |
199 | | - // #endregion |
200 | | - |
201 | 185 | // #region add, remove |
202 | 186 | if (!getInput('add') && !getInput('remove')) |
203 | 187 | throw new Error( |
@@ -227,57 +211,11 @@ async function checkInputs() { |
227 | 211 | // #endregion |
228 | 212 |
|
229 | 213 | // #region author_name, author_email |
230 | | - if (getInput('author_name') && getInput('author_email')) { |
231 | | - info('> Using author info from inputs...') |
232 | | - } else { |
233 | | - info('> Some author info is missing, filling from workflow event...') |
234 | | - let author = event?.head_commit?.author |
235 | | - |
236 | | - if (sha && !author) { |
237 | | - info( |
238 | | - '> Unable to get commit from workflow event: trying with the GitHub API...' |
239 | | - ) |
240 | | - |
241 | | - // https://docs.github.com/en/rest/reference/repos#get-a-commit--code-samples |
242 | | - const url = `https://api.github.com/repos/${process.env.GITHUB_REPOSITORY}/commits/${sha}`, |
243 | | - headers = token |
244 | | - ? { |
245 | | - Authorization: `Bearer ${token}` |
246 | | - } |
247 | | - : undefined, |
248 | | - commit = ( |
249 | | - await axios.get(url, { headers }).catch((err) => { |
250 | | - startGroup('Request error:') |
251 | | - info(`> Request URL: ${url}\b${err}`) |
252 | | - endGroup() |
253 | | - return undefined |
254 | | - }) |
255 | | - )?.data |
256 | | - |
257 | | - author = commit?.commit?.author |
258 | | - } |
259 | | - |
260 | | - if (typeof author == 'object') { |
261 | | - setDefault('author_name', author.name) |
262 | | - setDefault('author_email', author.email) |
263 | | - } |
264 | | - |
265 | | - if (!getInput('author_name') || !getInput('author_email')) { |
266 | | - const reason = !eventPath |
267 | | - ? 'event path' |
268 | | - : isPR |
269 | | - ? sha |
270 | | - ? 'fetch commit' |
271 | | - : 'find commit sha' |
272 | | - : !event?.head_commit |
273 | | - ? 'find commit' |
274 | | - : 'find commit author' |
275 | | - warning(`Unable to fetch author info: couldn't ${reason}.`) |
276 | | - setDefault('author_name', 'Add & Commit Action') |
277 | | - setDefault('author_email', '[email protected]') |
278 | | - } |
279 | | - } |
280 | | - |
| 214 | + setDefault('author_name', `${process.env.GITHUB_ACTOR}`) |
| 215 | + setDefault( |
| 216 | + 'author_email', |
| 217 | + `${process.env.GITHUB_ACTOR}@users.noreply.github.com` |
| 218 | + ) |
281 | 219 | info( |
282 | 220 | `> Using '${getInput('author_name')} <${getInput( |
283 | 221 | 'author_email' |
|
0 commit comments