Skip to content

Commit 43bfef4

Browse files
committed
Review @actions/github for updates
1 parent 23cc7b1 commit 43bfef4

File tree

7 files changed

+33
-16
lines changed

7 files changed

+33
-16
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ currently implemented by this tool.
2121
| ---------------------------------------------------------------------- | -------- |
2222
| [`@actions/artifact`](https://www.npmjs.com/package/@actions/artifact) | `2.3.2` |
2323
| [`@actions/core`](https://www.npmjs.com/package/@actions/core) | `1.11.1` |
24+
| [`@actions/github`](https://www.npmjs.com/package/@actions/github) | `6.0.0` |
2425

2526
## Changelog
2627

src/stubs/env.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ export const EnvMeta: EnvMetadata = {
1717

1818
/**
1919
* Resets the environment metadata
20-
*
21-
* @returns void
2220
*/
2321
export function ResetEnvMetadata(): void {
2422
EnvMeta.actionFile = ''

src/stubs/github/context.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
/**
2+
* Last Reviewed Commit: https://github.com/actions/toolkit/blob/930c89072712a3aac52d74b23338f00bb0cfcb24/packages/github/src/context.ts
3+
*/
14
import { existsSync, readFileSync } from 'fs'
25
import { EOL } from 'os'
3-
import { WebhookPayload } from './interfaces.js'
6+
import type { WebhookPayload } from './interfaces.js'
47

58
export class Context {
69
/**
@@ -29,7 +32,6 @@ export class Context {
2932
this.payload = {}
3033

3134
if (process.env.GITHUB_EVENT_PATH) {
32-
console.log(process.env.GITHUB_EVENT_PATH)
3335
if (existsSync(process.env.GITHUB_EVENT_PATH)) {
3436
this.payload = JSON.parse(
3537
readFileSync(process.env.GITHUB_EVENT_PATH, { encoding: 'utf8' })
@@ -76,12 +78,11 @@ export class Context {
7678
}
7779

7880
/* istanbul ignore next */
79-
if (this.payload.repository) {
81+
if (this.payload.repository)
8082
return {
8183
owner: this.payload.repository.owner.login,
8284
repo: this.payload.repository.name
8385
}
84-
}
8586

8687
/* istanbul ignore next */
8788
throw new Error(

src/stubs/github/github.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
/**
2-
* @github/local-action Modified
2+
* Last Reviewed Commit: https://github.com/actions/toolkit/blob/930c89072712a3aac52d74b23338f00bb0cfcb24/packages/github/src/github.ts
3+
*
4+
* @remarks
5+
*
6+
* - The `context` export is removed and defined in `commands/run.ts`. This is
7+
* so that the context can be defined after the environment file is loaded.
38
*/
49

5-
import { OctokitOptions, OctokitPlugin } from '@octokit/core/types'
10+
import type { OctokitOptions, OctokitPlugin } from '@octokit/core/types'
611
import { GitHub, getOctokitOptions } from './utils.js'
712

813
/**

src/stubs/github/interfaces.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1+
/**
2+
* Last Reviewed Commit: https://github.com/actions/toolkit/blob/930c89072712a3aac52d74b23338f00bb0cfcb24/packages/github/src/interfaces.ts
3+
*/
14
/* eslint-disable @typescript-eslint/no-explicit-any */
25

6+
/**
7+
* Repository Payload
8+
*/
39
export interface PayloadRepository {
410
[key: string]: any
511
full_name?: string
@@ -12,6 +18,9 @@ export interface PayloadRepository {
1218
html_url?: string
1319
}
1420

21+
/**
22+
* Webhook Payload
23+
*/
1524
export interface WebhookPayload {
1625
[key: string]: any
1726
repository?: PayloadRepository

src/stubs/github/internal/utils.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
/**
2-
* @github/local-action Modified
2+
* Last Reviewed Commit: https://github.com/actions/toolkit/blob/930c89072712a3aac52d74b23338f00bb0cfcb24/packages/github/src/internal/utils.ts
33
*/
44
/* istanbul ignore file */
55

66
import * as httpClient from '@actions/http-client'
7-
import { OctokitOptions } from '@octokit/core/types'
7+
import { type OctokitOptions } from '@octokit/core/types'
88
import * as http from 'http'
9-
import { ProxyAgent, fetch } from 'undici'
9+
import { type ProxyAgent, fetch } from 'undici'
1010

1111
/**
1212
* Returns the auth string to use for the request.
@@ -50,8 +50,7 @@ export function getProxyAgentDispatcher(
5050
): ProxyAgent | undefined {
5151
const hc = new httpClient.HttpClient()
5252

53-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
54-
return hc.getAgentDispatcher(destinationUrl) as any
53+
return hc.getAgentDispatcher(destinationUrl) as ProxyAgent | undefined
5554
}
5655

5756
/**
@@ -79,5 +78,5 @@ export function getProxyFetch(destinationUrl: string): typeof fetch {
7978
* @returns Base URL
8079
*/
8180
export function getApiBaseUrl(): string {
82-
return process.env['GITHUB_API_URL'] || 'https://api.github.com'
81+
return process.env.GITHUB_API_URL || 'https://api.github.com'
8382
}

src/stubs/github/utils.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
/**
2-
* @github/local-action Modified
2+
* Last Reviewed Commit: https://github.com/actions/toolkit/blob/930c89072712a3aac52d74b23338f00bb0cfcb24/packages/github/src/utils.ts
3+
*
4+
* @remarks
5+
*
6+
* - The `context` export is removed and defined in `commands/run.ts`. This is
7+
* so that the context can be defined after the environment file is loaded.
38
*/
49

510
import { Octokit } from '@octokit/core'
@@ -39,7 +44,6 @@ export function getOctokitOptions(
3944
const opts = Object.assign({}, options || {})
4045

4146
const auth = Utils.getAuthString(token, opts)
42-
4347
if (auth) opts.auth = auth
4448

4549
return opts

0 commit comments

Comments
 (0)