Compare commits

..

13 Commits

Author SHA1 Message Date
Tingluo Huang
450193c5ab Merge pull request #695 from actions/copilot/add-orchestration-id-user-agent
Add ACTIONS_ORCHESTRATION_ID to user-agent string
2026-01-07 10:23:37 -05:00
copilot-swe-agent[bot]
b67a972797 Change orchestration ID format to actions_orchestration_id
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-07 04:17:15 +00:00
copilot-swe-agent[bot]
c0078b2072 Simplify user-agent logic and update integration test
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-06 23:05:20 +00:00
copilot-swe-agent[bot]
c36bdc0a3a Fix user-agent to handle empty string correctly
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-06 22:55:13 +00:00
copilot-swe-agent[bot]
b588811d63 Revert package-lock.json changes to remove peer flags
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-06 22:46:11 +00:00
copilot-swe-agent[bot]
135f4fc944 Replace invalid characters with underscore instead of removing them
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-06 22:39:03 +00:00
copilot-swe-agent[bot]
8a9be95424 Move helper method to end of file and revert package-lock.json changes
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-06 22:30:38 +00:00
copilot-swe-agent[bot]
728b23b52d Remove orchestration-id test file
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-06 22:22:39 +00:00
copilot-swe-agent[bot]
f80dad6b51 Add underscore to valid orchestration ID characters
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-06 21:27:04 +00:00
copilot-swe-agent[bot]
baada7bb39 Apply prettier formatting to test file
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-06 21:15:37 +00:00
copilot-swe-agent[bot]
d053ab3e3c Add ACTIONS_ORCHESTRATION_ID to user-agent string
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-06 21:10:26 +00:00
copilot-swe-agent[bot]
4389015762 Initial plan for ACTIONS_ORCHESTRATION_ID user-agent support
Co-authored-by: TingluoHuang <1750815+TingluoHuang@users.noreply.github.com>
2026-01-06 21:07:40 +00:00
copilot-swe-agent[bot]
6599b4813b Initial plan 2026-01-06 21:02:44 +00:00
5 changed files with 47 additions and 11 deletions

View File

@@ -167,7 +167,7 @@ jobs:
exit 1
fi
echo "- Validating user-agent set to an empty string"
expected="octokit-core.js/"
expected="actions/github-script octokit-core.js/"
if [[ "${{steps.user-agent-empty.outputs.result}}" != "$expected"* ]]; then
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-empty.outputs.result}}"
exit 1

18
dist/index.js vendored
View File

@@ -36267,9 +36267,11 @@ async function main() {
const retries = parseInt(core.getInput('retries'));
const exemptStatusCodes = parseNumberArray(core.getInput('retry-exempt-status-codes'));
const [retryOpts, requestOpts] = getRetryOptions(retries, exemptStatusCodes, utils.defaults);
const baseUserAgent = userAgent || 'actions/github-script';
const finalUserAgent = getUserAgentWithOrchestrationId(baseUserAgent);
const opts = {
log: debug ? console : undefined,
userAgent: userAgent || undefined,
userAgent: finalUserAgent,
previews: previews ? previews.split(',') : undefined,
retry: retryOpts,
request: requestOpts
@@ -36313,6 +36315,20 @@ function handleError(err) {
console.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) {
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}`;
}
})();

14
package-lock.json generated
View File

@@ -23,7 +23,7 @@
"@types/jest": "^29.5.5",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"@vercel/ncc": "^0.38.4",
"@vercel/ncc": "^0.38.0",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
@@ -1942,9 +1942,9 @@
}
},
"node_modules/@vercel/ncc": {
"version": "0.38.4",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.4.tgz",
"integrity": "sha512-8LwjnlP39s08C08J5NstzriPvW1SP8Zfpp1BvC2sI35kPeZnHfxVkCwu4/+Wodgnd60UtT1n8K8zw+Mp7J9JmQ==",
"version": "0.38.0",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.0.tgz",
"integrity": "sha512-B4YKZMm/EqMptKSFyAq4q2SlgJe+VCmEH6Y8gf/E1pTlWbsUJpuH1ymik2Ex3aYO5mCWwV1kaSYHSQOT8+4vHA==",
"dev": true,
"bin": {
"ncc": "dist/ncc/cli.js"
@@ -8822,9 +8822,9 @@
}
},
"@vercel/ncc": {
"version": "0.38.4",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.4.tgz",
"integrity": "sha512-8LwjnlP39s08C08J5NstzriPvW1SP8Zfpp1BvC2sI35kPeZnHfxVkCwu4/+Wodgnd60UtT1n8K8zw+Mp7J9JmQ==",
"version": "0.38.0",
"resolved": "https://registry.npmjs.org/@vercel/ncc/-/ncc-0.38.0.tgz",
"integrity": "sha512-B4YKZMm/EqMptKSFyAq4q2SlgJe+VCmEH6Y8gf/E1pTlWbsUJpuH1ymik2Ex3aYO5mCWwV1kaSYHSQOT8+4vHA==",
"dev": true
},
"acorn": {

View File

@@ -52,7 +52,7 @@
"@types/jest": "^29.5.5",
"@typescript-eslint/eslint-plugin": "^6.7.5",
"@typescript-eslint/parser": "^6.7.5",
"@vercel/ncc": "^0.38.4",
"@vercel/ncc": "^0.38.0",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",

View File

@@ -39,9 +39,12 @@ async function main(): Promise<void> {
defaultGitHubOptions
)
const baseUserAgent = userAgent || 'actions/github-script'
const finalUserAgent = getUserAgentWithOrchestrationId(baseUserAgent)
const opts: Options = {
log: debug ? console : undefined,
userAgent: userAgent || undefined,
userAgent: finalUserAgent,
previews: previews ? previews.split(',') : undefined,
retry: retryOpts,
request: requestOpts
@@ -96,3 +99,20 @@ function handleError(err: any): void {
console.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}`
}