mirror of
https://github.com/actions/github-script.git
synced 2026-05-13 19:36:55 +00:00
Compare commits
1 Commits
copilot/fi
...
dependabot
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
adc37b7b4d |
18
.github/workflows/integration.yml
vendored
18
.github/workflows/integration.yml
vendored
@@ -155,21 +155,21 @@ jobs:
|
|||||||
result-encoding: string
|
result-encoding: string
|
||||||
- run: |
|
- run: |
|
||||||
echo "- Validating user-agent default"
|
echo "- Validating user-agent default"
|
||||||
actual="${{steps.user-agent-default.outputs.result}}"
|
expected="actions/github-script octokit-core.js/"
|
||||||
if [[ ! "$actual" =~ ^actions/github-script([[:space:]]actions_orchestration_id/[^[:space:]]+)?[[:space:]]octokit-core\.js/ ]]; then
|
if [[ "${{steps.user-agent-default.outputs.result}}" != "$expected"* ]]; then
|
||||||
echo $'::error::\u274C' "Expected user-agent to match 'actions/github-script [actions_orchestration_id/...] octokit-core.js/...', got $actual"
|
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-default.outputs.result}}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "- Validating user-agent set to a value"
|
echo "- Validating user-agent set to a value"
|
||||||
actual="${{steps.user-agent-set.outputs.result}}"
|
expected="foobar octokit-core.js/"
|
||||||
if [[ ! "$actual" =~ ^foobar([[:space:]]actions_orchestration_id/[^[:space:]]+)?[[:space:]]octokit-core\.js/ ]]; then
|
if [[ "${{steps.user-agent-set.outputs.result}}" != "$expected"* ]]; then
|
||||||
echo $'::error::\u274C' "Expected user-agent to match 'foobar [actions_orchestration_id/...] octokit-core.js/...', got $actual"
|
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-set.outputs.result}}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "- Validating user-agent set to an empty string"
|
echo "- Validating user-agent set to an empty string"
|
||||||
actual="${{steps.user-agent-empty.outputs.result}}"
|
expected="octokit-core.js/"
|
||||||
if [[ ! "$actual" =~ ^actions/github-script([[:space:]]actions_orchestration_id/[^[:space:]]+)?[[:space:]]octokit-core\.js/ ]]; then
|
if [[ "${{steps.user-agent-empty.outputs.result}}" != "$expected"* ]]; then
|
||||||
echo $'::error::\u274C' "Expected user-agent to match 'actions/github-script [actions_orchestration_id/...] octokit-core.js/...', got $actual"
|
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-empty.outputs.result}}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
||||||
|
|||||||
37306
dist/index.js
vendored
37306
dist/index.js
vendored
File diff suppressed because one or more lines are too long
1535
package-lock.json
generated
1535
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
17
package.json
17
package.json
@@ -11,7 +11,7 @@
|
|||||||
"types": "types/async-function.d.ts",
|
"types": "types/async-function.d.ts",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "npm run build:types && ncc build src/main.ts",
|
"build": "npm run build:types && ncc build src/main.ts",
|
||||||
"build:types": "tsc src/async-function.ts --target es2022 --module es2022 --moduleResolution bundler --declaration --emitDeclarationOnly --outDir types",
|
"build:types": "tsc src/async-function.ts -t es5 --declaration --allowJs --emitDeclarationOnly --outDir types",
|
||||||
"format:check": "prettier --check src __test__",
|
"format:check": "prettier --check src __test__",
|
||||||
"format:write": "prettier --write src __test__",
|
"format:write": "prettier --write src __test__",
|
||||||
"lint": "eslint src __test__",
|
"lint": "eslint src __test__",
|
||||||
@@ -28,11 +28,6 @@
|
|||||||
"^.+\\.ts$": [
|
"^.+\\.ts$": [
|
||||||
"ts-jest",
|
"ts-jest",
|
||||||
{
|
{
|
||||||
"tsconfig": {
|
|
||||||
"target": "es2022",
|
|
||||||
"module": "commonjs",
|
|
||||||
"moduleResolution": "bundler"
|
|
||||||
},
|
|
||||||
"diagnostics": {
|
"diagnostics": {
|
||||||
"ignoreCodes": [
|
"ignoreCodes": [
|
||||||
"151001"
|
"151001"
|
||||||
@@ -45,12 +40,12 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/core": "^1.10.1",
|
"@actions/core": "^1.10.1",
|
||||||
"@actions/exec": "^1.1.1",
|
"@actions/exec": "^1.1.1",
|
||||||
"@actions/github": "^9.0.0",
|
"@actions/github": "^6.0.0",
|
||||||
"@actions/glob": "^0.4.0",
|
"@actions/glob": "^0.4.0",
|
||||||
"@actions/io": "^1.1.3",
|
"@actions/io": "^1.1.3",
|
||||||
"@octokit/core": "^7.0.0",
|
"@octokit/core": "^5.0.1",
|
||||||
"@octokit/plugin-request-log": "^6.0.0",
|
"@octokit/plugin-request-log": "^4.0.0",
|
||||||
"@octokit/plugin-retry": "^8.0.0",
|
"@octokit/plugin-retry": "^6.0.1",
|
||||||
"@types/node": "^24.1.0"
|
"@types/node": "^24.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
@@ -58,7 +53,7 @@
|
|||||||
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
"@typescript-eslint/eslint-plugin": "^6.7.5",
|
||||||
"@typescript-eslint/parser": "^6.7.5",
|
"@typescript-eslint/parser": "^6.7.5",
|
||||||
"@vercel/ncc": "^0.38.0",
|
"@vercel/ncc": "^0.38.0",
|
||||||
"eslint": "^8.51.0",
|
"eslint": "^9.38.0",
|
||||||
"eslint-config-prettier": "^9.0.0",
|
"eslint-config-prettier": "^9.0.0",
|
||||||
"eslint-plugin-prettier": "^5.0.1",
|
"eslint-plugin-prettier": "^5.0.1",
|
||||||
"husky": "^9.1.1",
|
"husky": "^9.1.1",
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import * as exec from '@actions/exec'
|
import * as exec from '@actions/exec'
|
||||||
import {context as _ghContext, GitHub} from '@actions/github/lib/utils'
|
import {Context} from '@actions/github/lib/context'
|
||||||
|
import {GitHub} from '@actions/github/lib/utils'
|
||||||
import * as glob from '@actions/glob'
|
import * as glob from '@actions/glob'
|
||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
|
|
||||||
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor
|
const AsyncFunction = Object.getPrototypeOf(async () => null).constructor
|
||||||
|
|
||||||
export declare type AsyncFunctionArguments = {
|
export declare type AsyncFunctionArguments = {
|
||||||
context: typeof _ghContext
|
context: Context
|
||||||
core: typeof core
|
core: typeof core
|
||||||
github: InstanceType<typeof GitHub>
|
github: InstanceType<typeof GitHub>
|
||||||
octokit: InstanceType<typeof GitHub>
|
octokit: InstanceType<typeof GitHub>
|
||||||
|
|||||||
22
src/main.ts
22
src/main.ts
@@ -39,12 +39,9 @@ async function main(): Promise<void> {
|
|||||||
defaultGitHubOptions
|
defaultGitHubOptions
|
||||||
)
|
)
|
||||||
|
|
||||||
const baseUserAgent = userAgent || 'actions/github-script'
|
|
||||||
const finalUserAgent = getUserAgentWithOrchestrationId(baseUserAgent)
|
|
||||||
|
|
||||||
const opts: Options = {
|
const opts: Options = {
|
||||||
log: debug ? console : undefined,
|
log: debug ? console : undefined,
|
||||||
userAgent: finalUserAgent,
|
userAgent: userAgent || undefined,
|
||||||
previews: previews ? previews.split(',') : undefined,
|
previews: previews ? previews.split(',') : undefined,
|
||||||
retry: retryOpts,
|
retry: retryOpts,
|
||||||
request: requestOpts
|
request: requestOpts
|
||||||
@@ -99,20 +96,3 @@ function handleError(err: any): void {
|
|||||||
console.error(err)
|
console.error(err)
|
||||||
core.setFailed(`Unhandled error: ${err}`)
|
core.setFailed(`Unhandled error: ${err}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the user agent string with orchestration ID appended if available
|
|
||||||
* @param userAgent The base user agent string
|
|
||||||
* @returns The user agent string with orchestration ID appended if ACTIONS_ORCHESTRATION_ID is set
|
|
||||||
*/
|
|
||||||
function getUserAgentWithOrchestrationId(userAgent: string): string {
|
|
||||||
const orchestrationId = process.env['ACTIONS_ORCHESTRATION_ID']
|
|
||||||
if (!orchestrationId) {
|
|
||||||
return userAgent
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sanitize orchestration ID - replace invalid characters with underscore
|
|
||||||
const sanitized = orchestrationId.replace(/[^a-zA-Z0-9._-]/g, '_')
|
|
||||||
|
|
||||||
return `${userAgent} actions_orchestration_id/${sanitized}`
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as core from '@actions/core'
|
import * as core from '@actions/core'
|
||||||
import {OctokitOptions} from '@octokit/core/types'
|
import {OctokitOptions} from '@octokit/core/dist-types/types'
|
||||||
import {RequestRequestOptions} from '@octokit/types'
|
import {RequestRequestOptions} from '@octokit/types'
|
||||||
|
|
||||||
export type RetryOptions = {
|
export type RetryOptions = {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
"target": "es2022",
|
"target": "es2018",
|
||||||
"module": "es2022",
|
"moduleResolution": "node",
|
||||||
"moduleResolution": "bundler",
|
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"forceConsistentCasingInFileNames": true
|
"forceConsistentCasingInFileNames": true
|
||||||
},
|
},
|
||||||
|
|||||||
5
types/async-function.d.ts
vendored
5
types/async-function.d.ts
vendored
@@ -1,11 +1,12 @@
|
|||||||
/// <reference types="node" />
|
/// <reference types="node" />
|
||||||
import * as core from '@actions/core';
|
import * as core from '@actions/core';
|
||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import { context as _ghContext, GitHub } from '@actions/github/lib/utils';
|
import { Context } from '@actions/github/lib/context';
|
||||||
|
import { GitHub } from '@actions/github/lib/utils';
|
||||||
import * as glob from '@actions/glob';
|
import * as glob from '@actions/glob';
|
||||||
import * as io from '@actions/io';
|
import * as io from '@actions/io';
|
||||||
export declare type AsyncFunctionArguments = {
|
export declare type AsyncFunctionArguments = {
|
||||||
context: typeof _ghContext;
|
context: Context;
|
||||||
core: typeof core;
|
core: typeof core;
|
||||||
github: InstanceType<typeof GitHub>;
|
github: InstanceType<typeof GitHub>;
|
||||||
octokit: InstanceType<typeof GitHub>;
|
octokit: InstanceType<typeof GitHub>;
|
||||||
|
|||||||
Reference in New Issue
Block a user