mirror of
https://github.com/actions/github-script.git
synced 2026-05-13 11:26:55 +00:00
Compare commits
1 Commits
salmanmkc/
...
benwells/p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
258926b0d3 |
@@ -3,9 +3,9 @@ description: 'Set up node and install dependencies'
|
|||||||
runs:
|
runs:
|
||||||
using: 'composite'
|
using: 'composite'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '24.x'
|
node-version: '20.x'
|
||||||
cache: npm
|
cache: npm
|
||||||
|
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
|
|||||||
16
.github/dependabot.yml
vendored
16
.github/dependabot.yml
vendored
@@ -1,16 +0,0 @@
|
|||||||
version: 2
|
|
||||||
updates:
|
|
||||||
- package-ecosystem: 'github-actions'
|
|
||||||
directory: '/'
|
|
||||||
schedule:
|
|
||||||
interval: 'weekly'
|
|
||||||
|
|
||||||
- package-ecosystem: 'github-actions'
|
|
||||||
directory: '/.github/actions/install-dependencies'
|
|
||||||
schedule:
|
|
||||||
interval: 'weekly'
|
|
||||||
|
|
||||||
- package-ecosystem: 'npm'
|
|
||||||
directory: '/'
|
|
||||||
schedule:
|
|
||||||
interval: 'weekly'
|
|
||||||
7
.github/workflows/check-dist.yml
vendored
7
.github/workflows/check-dist.yml
vendored
@@ -13,15 +13,12 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
check-dist:
|
check-dist:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- uses: ./.github/actions/install-dependencies
|
- uses: ./.github/actions/install-dependencies
|
||||||
|
|
||||||
@@ -38,7 +35,7 @@ jobs:
|
|||||||
id: diff
|
id: diff
|
||||||
|
|
||||||
# If index.js was different than expected, upload the expected version as an artifact
|
# If index.js was different than expected, upload the expected version as an artifact
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v3
|
||||||
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
if: ${{ failure() && steps.diff.conclusion == 'failure' }}
|
||||||
with:
|
with:
|
||||||
name: dist
|
name: dist
|
||||||
|
|||||||
5
.github/workflows/ci.yml
vendored
5
.github/workflows/ci.yml
vendored
@@ -6,14 +6,11 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
ci:
|
ci:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: ./.github/actions/install-dependencies
|
- uses: ./.github/actions/install-dependencies
|
||||||
- run: npm run style:check
|
- run: npm run style:check
|
||||||
- run: npm test
|
- run: npm test
|
||||||
|
|||||||
8
.github/workflows/codeql-analysis.yml
vendored
8
.github/workflows/codeql-analysis.yml
vendored
@@ -38,11 +38,11 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v3
|
uses: github/codeql-action/init@v2
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
@@ -56,7 +56,7 @@ jobs:
|
|||||||
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
# If this step fails, then you should remove it and run the build manually (see below)
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
- name: Autobuild
|
- name: Autobuild
|
||||||
uses: github/codeql-action/autobuild@v3
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
|
||||||
# ℹ️ Command-line programs to run using the OS shell.
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
|
||||||
@@ -69,4 +69,4 @@ jobs:
|
|||||||
# ./location_of_script_within_repo/buildscript.sh
|
# ./location_of_script_within_repo/buildscript.sh
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v3
|
uses: github/codeql-action/analyze@v2
|
||||||
|
|||||||
67
.github/workflows/integration.yml
vendored
67
.github/workflows/integration.yml
vendored
@@ -6,15 +6,12 @@ on:
|
|||||||
pull_request:
|
pull_request:
|
||||||
branches: [main]
|
branches: [main]
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test-return:
|
test-return:
|
||||||
name: 'Integration test: return'
|
name: 'Integration test: return'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- id: output-set
|
- id: output-set
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -34,7 +31,7 @@ jobs:
|
|||||||
name: 'Integration test: relative-path require'
|
name: 'Integration test: relative-path require'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- id: relative-require
|
- id: relative-require
|
||||||
uses: ./
|
uses: ./
|
||||||
with:
|
with:
|
||||||
@@ -42,7 +39,7 @@ jobs:
|
|||||||
result-encoding: string
|
result-encoding: string
|
||||||
- run: |
|
- run: |
|
||||||
echo "- Validating relative require output"
|
echo "- Validating relative require output"
|
||||||
if [[ "${{steps.relative-require.outputs.result}}" != "@actions/github-script" ]]; then
|
if [[ "${{steps.relative-require.outputs.result}}" != "github-script" ]]; then
|
||||||
echo $'::error::\u274C' "Expected '$expected', got ${{steps.relative-require.outputs.result}}"
|
echo $'::error::\u274C' "Expected '$expected', got ${{steps.relative-require.outputs.result}}"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -52,7 +49,7 @@ jobs:
|
|||||||
name: 'Integration test: npm package require'
|
name: 'Integration test: npm package require'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: ./.github/actions/install-dependencies
|
- uses: ./.github/actions/install-dependencies
|
||||||
- id: npm-require
|
- id: npm-require
|
||||||
uses: ./
|
uses: ./
|
||||||
@@ -72,7 +69,7 @@ jobs:
|
|||||||
name: 'Integration test: GraphQL previews option'
|
name: 'Integration test: GraphQL previews option'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: ./.github/actions/install-dependencies
|
- uses: ./.github/actions/install-dependencies
|
||||||
- id: previews-default
|
- id: previews-default
|
||||||
name: Default previews not set
|
name: Default previews not set
|
||||||
@@ -125,7 +122,7 @@ jobs:
|
|||||||
name: 'Integration test: user-agent option'
|
name: 'Integration test: user-agent option'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: ./.github/actions/install-dependencies
|
- uses: ./.github/actions/install-dependencies
|
||||||
- id: user-agent-default
|
- id: user-agent-default
|
||||||
name: Default user-agent not set
|
name: Default user-agent not set
|
||||||
@@ -155,51 +152,21 @@ jobs:
|
|||||||
result-encoding: string
|
result-encoding: string
|
||||||
- run: |
|
- run: |
|
||||||
echo "- Validating user-agent default"
|
echo "- Validating user-agent default"
|
||||||
ua="${{steps.user-agent-default.outputs.result}}"
|
expected="actions/github-script octokit-core.js/"
|
||||||
if [[ "$ua" != "actions/github-script octokit-core.js/"* ]] && [[ "$ua" != "actions/github-script actions_orchestration_id/"* ]]; then
|
if [[ "${{steps.user-agent-default.outputs.result}}" != "$expected"* ]]; then
|
||||||
echo $'::error::\u274C' "Expected user-agent to start with 'actions/github-script', got $ua"
|
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"
|
||||||
ua="${{steps.user-agent-set.outputs.result}}"
|
expected="foobar octokit-core.js/"
|
||||||
if [[ "$ua" != "foobar octokit-core.js/"* ]] && [[ "$ua" != "foobar actions_orchestration_id/"* ]]; then
|
if [[ "${{steps.user-agent-set.outputs.result}}" != "$expected"* ]]; then
|
||||||
echo $'::error::\u274C' "Expected user-agent to start with 'foobar', got $ua"
|
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"
|
||||||
ua="${{steps.user-agent-empty.outputs.result}}"
|
expected="octokit-core.js/"
|
||||||
if [[ "$ua" != "actions/github-script octokit-core.js/"* ]] && [[ "$ua" != "actions/github-script actions_orchestration_id/"* ]]; then
|
if [[ "${{steps.user-agent-empty.outputs.result}}" != "$expected"* ]]; then
|
||||||
echo $'::error::\u274C' "Expected user-agent to start with 'actions/github-script', got $ua"
|
echo $'::error::\u274C' "Expected user-agent to start with '$expected', got ${{steps.user-agent-empty.outputs.result}}"
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
|
|
||||||
|
|
||||||
test-get-octokit:
|
|
||||||
name: 'Integration test: getOctokit'
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- name: Create secondary client with getOctokit
|
|
||||||
uses: ./
|
|
||||||
id: secondary-client
|
|
||||||
env:
|
|
||||||
APP_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
script: |
|
|
||||||
const appOctokit = getOctokit(process.env.APP_TOKEN)
|
|
||||||
const {data} = await appOctokit.rest.repos.get({
|
|
||||||
owner: context.repo.owner,
|
|
||||||
repo: context.repo.repo
|
|
||||||
})
|
|
||||||
|
|
||||||
return `${appOctokit !== github}:${data.full_name}`
|
|
||||||
result-encoding: string
|
|
||||||
- run: |
|
|
||||||
echo "- Validating secondary client output"
|
|
||||||
expected="true:${{ github.repository }}"
|
|
||||||
if [[ "${{steps.secondary-client.outputs.result}}" != "$expected" ]]; then
|
|
||||||
echo $'::error::\u274C' "Expected '$expected', got ${{steps.secondary-client.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
|
||||||
@@ -212,7 +179,7 @@ jobs:
|
|||||||
name: "Integration test: debug option (runner.debug mode ${{ matrix.environment && 'enabled' || 'disabled' }})"
|
name: "Integration test: debug option (runner.debug mode ${{ matrix.environment && 'enabled' || 'disabled' }})"
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: ./.github/actions/install-dependencies
|
- uses: ./.github/actions/install-dependencies
|
||||||
- id: debug-default
|
- id: debug-default
|
||||||
name: Default debug not set
|
name: Default debug not set
|
||||||
@@ -286,7 +253,7 @@ jobs:
|
|||||||
name: 'Integration test: base-url option'
|
name: 'Integration test: base-url option'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: ./.github/actions/install-dependencies
|
- uses: ./.github/actions/install-dependencies
|
||||||
|
|
||||||
- id: base-url-default
|
- id: base-url-default
|
||||||
|
|||||||
14
.github/workflows/licensed.yml
vendored
14
.github/workflows/licensed.yml
vendored
@@ -8,23 +8,17 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
name: Check licenses
|
name: Check licenses
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # prefer to use a full fetch for licensed workflows
|
fetch-depth: 0 # prefer to use a full fetch for licensed workflows
|
||||||
- uses: ruby/setup-ruby@354a1ad156761f5ee2b7b13fa8e09943a5e8d252 # v1.229.0
|
# https://github.com/jonabc/setup-licensed/releases/tag/v1.1.1
|
||||||
|
- uses: jonabc/setup-licensed@82c5f4d19e8968efa74a25b132922382c2671fe2
|
||||||
with:
|
with:
|
||||||
ruby-version: ruby
|
version: '3.x'
|
||||||
- uses: github/setup-licensed@v1
|
|
||||||
with:
|
|
||||||
version: '4.x'
|
|
||||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
- uses: ./.github/actions/install-dependencies
|
- uses: ./.github/actions/install-dependencies
|
||||||
- run: licensed status
|
- run: licensed status
|
||||||
|
|||||||
@@ -17,4 +17,4 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Publish
|
- name: Publish
|
||||||
id: publish
|
id: publish
|
||||||
uses: actions/publish-immutable-action@0.0.4
|
uses: actions/publish-immutable-action@0.0.3
|
||||||
|
|||||||
6
.github/workflows/pull-request-test.yml
vendored
6
.github/workflows/pull-request-test.yml
vendored
@@ -5,15 +5,11 @@ on:
|
|||||||
branches: [main]
|
branches: [main]
|
||||||
types: [opened, synchronize]
|
types: [opened, synchronize]
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
pull-requests: write
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pull-request-test:
|
pull-request-test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: ./
|
- uses: ./
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
|
|||||||
31
.github/workflows/stale.yml
vendored
Normal file
31
.github/workflows/stale.yml
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
name: Stale Issues & PRs
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * *'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
mark_stale:
|
||||||
|
name: Mark issues and PRs as stale
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/stale@v3
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
exempt-issue-labels: Not Stale
|
||||||
|
exempt-pr-labels: Not Stale
|
||||||
|
stale-issue-message: >
|
||||||
|
This issue is stale because it has been open for 60 days with no
|
||||||
|
activity. Remove the "Stale" label or comment on the issue, or it
|
||||||
|
will be closed in 7 days.
|
||||||
|
stale-pr-message: >
|
||||||
|
This pull request is stale because it has been open for 60 days
|
||||||
|
with no activity. Remove the "Stale" label or comment on the pull
|
||||||
|
request, or it will be closed in 7 days.
|
||||||
|
close-issue-message: >
|
||||||
|
This issue has been marked as stale and closed due to no activity
|
||||||
|
on it.
|
||||||
|
close-pr-message: >
|
||||||
|
This pull request has been marked as stale and closed due to no
|
||||||
|
activity on it.
|
||||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
/node_modules/
|
/node_modules/
|
||||||
|
!/.vscode/
|
||||||
2
.licenses/npm/@types/node.dep.yml
generated
2
.licenses/npm/@types/node.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: "@types/node"
|
name: "@types/node"
|
||||||
version: 24.1.0
|
version: 20.9.0
|
||||||
type: npm
|
type: npm
|
||||||
summary: TypeScript definitions for node
|
summary: TypeScript definitions for node
|
||||||
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node
|
homepage: https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/node
|
||||||
|
|||||||
6
.licenses/npm/undici-types.dep.yml
generated
6
.licenses/npm/undici-types.dep.yml
generated
@@ -1,17 +1,15 @@
|
|||||||
---
|
---
|
||||||
name: undici-types
|
name: undici-types
|
||||||
version: 7.8.0
|
version: 5.26.5
|
||||||
type: npm
|
type: npm
|
||||||
summary: A stand-alone types package for Undici
|
summary: A stand-alone types package for Undici
|
||||||
homepage: https://undici.nodejs.org
|
homepage: https://undici.nodejs.org
|
||||||
license: mit
|
license: mit
|
||||||
licenses:
|
licenses:
|
||||||
- sources: LICENSE
|
- sources: Auto-generated MIT license text
|
||||||
text: |
|
text: |
|
||||||
MIT License
|
MIT License
|
||||||
|
|
||||||
Copyright (c) Matteo Collina and Undici contributors
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
in the Software without restriction, including without limitation the rights
|
in the Software without restriction, including without limitation the rights
|
||||||
|
|||||||
2
.licenses/npm/undici.dep.yml
generated
2
.licenses/npm/undici.dep.yml
generated
@@ -1,6 +1,6 @@
|
|||||||
---
|
---
|
||||||
name: undici
|
name: undici
|
||||||
version: 5.28.5
|
version: 5.26.3
|
||||||
type: npm
|
type: npm
|
||||||
summary: An HTTP/1.1 client, written from scratch for Node.js
|
summary: An HTTP/1.1 client, written from scratch for Node.js
|
||||||
homepage: https://undici.nodejs.org
|
homepage: https://undici.nodejs.org
|
||||||
|
|||||||
10
.vscode/settings.json
vendored
Normal file
10
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"editor.formatOnSave": true,
|
||||||
|
"editor.codeActionsOnSave": {
|
||||||
|
"source.organizeImports": true
|
||||||
|
},
|
||||||
|
"files.exclude": {
|
||||||
|
"**/dist": true,
|
||||||
|
"**/node_modules": true
|
||||||
|
}
|
||||||
|
}
|
||||||
184
README.md
184
README.md
@@ -7,27 +7,7 @@
|
|||||||
This action makes it easy to quickly write a script in your workflow that
|
This action makes it easy to quickly write a script in your workflow that
|
||||||
uses the GitHub API and the workflow run context.
|
uses the GitHub API and the workflow run context.
|
||||||
|
|
||||||
### Note
|
To use this action, provide an input named `script` that contains the body of an asynchronous function call.
|
||||||
|
|
||||||
Thank you for your interest in this GitHub action, however, right now we are not taking contributions.
|
|
||||||
|
|
||||||
We continue to focus our resources on strategic areas that help our customers be successful while making developers' lives easier. While GitHub Actions remains a key part of this vision, we are allocating resources towards other areas of Actions and are not taking contributions to this repository at this time. The GitHub public roadmap is the best place to follow along for any updates on features we’re working on and what stage they’re in.
|
|
||||||
|
|
||||||
We are taking the following steps to better direct requests related to GitHub Actions, including:
|
|
||||||
|
|
||||||
1. We will be directing questions and support requests to our [Community Discussions area](https://github.com/orgs/community/discussions/categories/actions)
|
|
||||||
|
|
||||||
2. High Priority bugs can be reported through Community Discussions or you can report these to our support team https://support.github.com/contact/bug-report.
|
|
||||||
|
|
||||||
3. Security Issues should be handled as per our [security.md](security.md)
|
|
||||||
|
|
||||||
We will still provide security updates for this project and fix major breaking changes during this time.
|
|
||||||
|
|
||||||
You are welcome to still raise bugs in this repo.
|
|
||||||
|
|
||||||
### This action
|
|
||||||
|
|
||||||
To use this action, provide an input named `script` that contains the body of an asynchronous JavaScript function call.
|
|
||||||
The following arguments will be provided:
|
The following arguments will be provided:
|
||||||
|
|
||||||
- `github` A pre-authenticated
|
- `github` A pre-authenticated
|
||||||
@@ -53,14 +33,6 @@ documentation.
|
|||||||
|
|
||||||
## Breaking Changes
|
## Breaking Changes
|
||||||
|
|
||||||
### V8
|
|
||||||
|
|
||||||
Version 8 of this action updated the runtime to Node 24 - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions
|
|
||||||
|
|
||||||
All scripts are now run with Node 24 instead of Node 20 and are affected by any breaking changes between Node 20 and 24.
|
|
||||||
|
|
||||||
**This requires a minimum Actions Runner version of [v2.327.1](https://github.com/actions/runner/releases/tag/v2.327.1)**
|
|
||||||
|
|
||||||
### V7
|
### V7
|
||||||
|
|
||||||
Version 7 of this action updated the runtime to Node 20 - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions
|
Version 7 of this action updated the runtime to Node 20 - https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions#runs-for-javascript-actions
|
||||||
@@ -87,38 +59,13 @@ For example, `github.issues.createComment` in V4 becomes `github.rest.issues.cre
|
|||||||
|
|
||||||
See [development.md](/docs/development.md).
|
See [development.md](/docs/development.md).
|
||||||
|
|
||||||
## Passing inputs to the script
|
|
||||||
|
|
||||||
Actions expressions are evaluated before the `script` is passed to the action, so the result of any expressions
|
|
||||||
*will be evaluated as JavaScript code*.
|
|
||||||
|
|
||||||
It's highly recommended to *not* evaluate expressions directly in the `script` to avoid
|
|
||||||
[script injections](https://docs.github.com/actions/security-for-github-actions/security-guides/security-hardening-for-github-actions#understanding-the-risk-of-script-injections)
|
|
||||||
and potential `SyntaxError`s when the expression is not valid JavaScript code (particularly when it comes to improperly escaped strings).
|
|
||||||
|
|
||||||
To pass inputs, set `env` vars on the action step and reference them in your script with `process.env`:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
- uses: actions/github-script@v8
|
|
||||||
env:
|
|
||||||
TITLE: ${{ github.event.pull_request.title }}
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const title = process.env.TITLE;
|
|
||||||
if (title.startsWith('octocat')) {
|
|
||||||
console.log("PR title starts with 'octocat'");
|
|
||||||
} else {
|
|
||||||
console.error("PR title did not start with 'octocat'");
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||
## Reading step results
|
## Reading step results
|
||||||
|
|
||||||
The return value of the script will be in the step's outputs under the
|
The return value of the script will be in the step's outputs under the
|
||||||
"result" key.
|
"result" key.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
id: set-result
|
id: set-result
|
||||||
with:
|
with:
|
||||||
script: return "Hello!"
|
script: return "Hello!"
|
||||||
@@ -137,7 +84,7 @@ output of a github-script step. For some workflows, string encoding is preferred
|
|||||||
`result-encoding` input:
|
`result-encoding` input:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
id: my-script
|
id: my-script
|
||||||
with:
|
with:
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
@@ -149,7 +96,7 @@ output of a github-script step. For some workflows, string encoding is preferred
|
|||||||
By default, requests made with the `github` instance will not be retried. You can configure this with the `retries` option:
|
By default, requests made with the `github` instance will not be retried. You can configure this with the `retries` option:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
id: my-script
|
id: my-script
|
||||||
with:
|
with:
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
@@ -167,7 +114,7 @@ In this example, request failures from `github.rest.issues.get()` will be retrie
|
|||||||
You can also configure which status codes should be exempt from retries via the `retry-exempt-status-codes` option:
|
You can also configure which status codes should be exempt from retries via the `retry-exempt-status-codes` option:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
id: my-script
|
id: my-script
|
||||||
with:
|
with:
|
||||||
result-encoding: string
|
result-encoding: string
|
||||||
@@ -185,6 +132,26 @@ By default, the following status codes will not be retried: `400, 401, 403, 404,
|
|||||||
|
|
||||||
These retries are implemented using the [octokit/plugin-retry.js](https://github.com/octokit/plugin-retry.js) plugin. The retries use [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) to space out retries. ([source](https://github.com/octokit/plugin-retry.js/blob/9a2443746c350b3beedec35cf26e197ea318a261/src/error-request.ts#L13))
|
These retries are implemented using the [octokit/plugin-retry.js](https://github.com/octokit/plugin-retry.js) plugin. The retries use [exponential backoff](https://en.wikipedia.org/wiki/Exponential_backoff) to space out retries. ([source](https://github.com/octokit/plugin-retry.js/blob/9a2443746c350b3beedec35cf26e197ea318a261/src/error-request.ts#L13))
|
||||||
|
|
||||||
|
## Recommended Permissions
|
||||||
|
|
||||||
|
The permissions required for the `GITHUB_TOKEN` in your workflow vary depending on how you use `github-script`. To ensure secure and efficient use of this action, we recommend reviewing and setting the least privileges necessary for your use case.
|
||||||
|
|
||||||
|
### Determine the Required Permissions
|
||||||
|
|
||||||
|
1. **`GITHUB_TOKEN` Authentication**
|
||||||
|
GitHub automatically provides a `GITHUB_TOKEN` for workflows. You can customize the permissions granted to this token. Refer to the documentation for details:
|
||||||
|
[Permissions for the `GITHUB_TOKEN`](https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#permissions-for-the-github_token)
|
||||||
|
|
||||||
|
2. **API Calls with Installation Access Tokens**
|
||||||
|
If you're using `github-script` to make API calls requiring installation access tokens, ensure the permissions are configured appropriately for those endpoints. Learn more here:
|
||||||
|
[Permissions for installation access tokens](https://docs.github.com/en/rest/authentication/endpoints-available-for-github-app-installation-access-tokens)
|
||||||
|
|
||||||
|
### General Best Practices
|
||||||
|
|
||||||
|
- Use the principle of least privilege: Only grant the specific permissions needed for your workflow.
|
||||||
|
- Regularly audit and review your workflows to ensure permissions remain appropriate for your use cases.
|
||||||
|
- Test your workflows with the intended permissions to verify they work as expected without over-permissioning.
|
||||||
|
|
||||||
## Examples
|
## Examples
|
||||||
|
|
||||||
Note that `github-token` is optional in this action, and the input is there
|
Note that `github-token` is optional in this action, and the input is there
|
||||||
@@ -196,7 +163,7 @@ By default, github-script will use the token provided to your workflow.
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: View context attributes
|
- name: View context attributes
|
||||||
uses: actions/github-script@v8
|
uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: console.log(context)
|
script: console.log(context)
|
||||||
```
|
```
|
||||||
@@ -212,7 +179,7 @@ jobs:
|
|||||||
comment:
|
comment:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
github.rest.issues.createComment({
|
github.rest.issues.createComment({
|
||||||
@@ -234,7 +201,7 @@ jobs:
|
|||||||
apply-label:
|
apply-label:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
github.rest.issues.addLabels({
|
github.rest.issues.addLabels({
|
||||||
@@ -256,7 +223,7 @@ jobs:
|
|||||||
welcome:
|
welcome:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
// Get a list of all issues created by the PR opener
|
// Get a list of all issues created by the PR opener
|
||||||
@@ -301,7 +268,7 @@ jobs:
|
|||||||
diff:
|
diff:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const diff_url = context.payload.pull_request.diff_url
|
const diff_url = context.payload.pull_request.diff_url
|
||||||
@@ -325,7 +292,7 @@ jobs:
|
|||||||
list-issues:
|
list-issues:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const query = `query($owner:String!, $name:String!, $label:String!) {
|
const query = `query($owner:String!, $name:String!, $label:String!) {
|
||||||
@@ -358,8 +325,8 @@ jobs:
|
|||||||
echo-input:
|
echo-input:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const script = require('./path/to/script.js')
|
const script = require('./path/to/script.js')
|
||||||
@@ -396,8 +363,8 @@ jobs:
|
|||||||
echo-input:
|
echo-input:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
env:
|
env:
|
||||||
SHA: '${{env.parentSHA}}'
|
SHA: '${{env.parentSHA}}'
|
||||||
with:
|
with:
|
||||||
@@ -434,14 +401,14 @@ jobs:
|
|||||||
echo-input:
|
echo-input:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/setup-node@v4
|
- uses: actions/setup-node@v3
|
||||||
with:
|
with:
|
||||||
node-version: '20.x'
|
node-version: '20.x'
|
||||||
- run: npm ci
|
- run: npm ci
|
||||||
# or one-off:
|
# or one-off:
|
||||||
- run: npm install execa
|
- run: npm install execa
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const execa = require('execa')
|
const execa = require('execa')
|
||||||
@@ -470,8 +437,8 @@ jobs:
|
|||||||
print-stuff:
|
print-stuff:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v3
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
const { default: printStuff } = await import('${{ github.workspace }}/src/print-stuff.js')
|
const { default: printStuff } = await import('${{ github.workspace }}/src/print-stuff.js')
|
||||||
@@ -482,21 +449,42 @@ jobs:
|
|||||||
### Use scripts with jsDoc support
|
### Use scripts with jsDoc support
|
||||||
|
|
||||||
If you want type support for your scripts, you could use the command below to install the
|
If you want type support for your scripts, you could use the command below to install the
|
||||||
`@actions/github-script` type declaration.
|
`github-script` type declaration.
|
||||||
```sh
|
```sh
|
||||||
$ npm i -D @actions/github-script@github:actions/github-script
|
$ npm i -D @types/github-script@github:actions/github-script
|
||||||
```
|
```
|
||||||
|
|
||||||
And then add the `jsDoc` declaration to your script like this:
|
And then add the `jsDoc` declaration to your script like this:
|
||||||
```js
|
```js
|
||||||
// @ts-check
|
// @ts-check
|
||||||
/** @param {import('@actions/github-script').AsyncFunctionArguments} AsyncFunctionArguments */
|
/** @param {import('@types/github-script').AsyncFunctionArguments} AsyncFunctionArguments */
|
||||||
export default async ({ core, context }) => {
|
export default async ({ core, context }) => {
|
||||||
core.debug("Running something at the moment");
|
core.debug("Running something at the moment");
|
||||||
return context.actor;
|
return context.actor;
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Use env as input
|
||||||
|
|
||||||
|
You can set env vars to use them in your script:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
echo-input:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/github-script@v7
|
||||||
|
env:
|
||||||
|
FIRST_NAME: Mona
|
||||||
|
LAST_NAME: Octocat
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
const { FIRST_NAME, LAST_NAME } = process.env
|
||||||
|
|
||||||
|
console.log(`Hello ${FIRST_NAME} ${LAST_NAME}`)
|
||||||
|
```
|
||||||
|
|
||||||
### Using a separate GitHub token
|
### Using a separate GitHub token
|
||||||
|
|
||||||
@@ -515,7 +503,7 @@ jobs:
|
|||||||
apply-label:
|
apply-label:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/github-script@v8
|
- uses: actions/github-script@v7
|
||||||
with:
|
with:
|
||||||
github-token: ${{ secrets.MY_PAT }}
|
github-token: ${{ secrets.MY_PAT }}
|
||||||
script: |
|
script: |
|
||||||
@@ -526,45 +514,3 @@ jobs:
|
|||||||
labels: ['Triage']
|
labels: ['Triage']
|
||||||
})
|
})
|
||||||
```
|
```
|
||||||
|
|
||||||
### Using exec package
|
|
||||||
|
|
||||||
The provided [@actions/exec](https://github.com/actions/toolkit/tree/main/packages/exec) package allows to execute command or tools in a cross platform way:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
on: push
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
use-exec:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/github-script@v8
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const exitCode = await exec.exec('echo', ['hello'])
|
|
||||||
|
|
||||||
console.log(exitCode)
|
|
||||||
```
|
|
||||||
|
|
||||||
`exec` packages provides `getExecOutput` function to retrieve stdout and stderr from executed command:
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
on: push
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
use-get-exec-output:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
- uses: actions/github-script@v8
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const {
|
|
||||||
exitCode,
|
|
||||||
stdout,
|
|
||||||
stderr
|
|
||||||
} = await exec.getExecOutput('echo', ['hello']);
|
|
||||||
|
|
||||||
console.log(exitCode, stdout, stderr)
|
|
||||||
```
|
|
||||||
|
|||||||
@@ -8,94 +8,6 @@ describe('callAsyncFunction', () => {
|
|||||||
expect(result).toEqual('bar')
|
expect(result).toEqual('bar')
|
||||||
})
|
})
|
||||||
|
|
||||||
test('passes getOctokit through the script context', async () => {
|
|
||||||
const getOctokit = jest.fn().mockReturnValue('secondary-client')
|
|
||||||
|
|
||||||
const result = await callAsyncFunction(
|
|
||||||
{getOctokit} as any,
|
|
||||||
"return getOctokit('token')"
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(getOctokit).toHaveBeenCalledWith('token')
|
|
||||||
expect(result).toEqual('secondary-client')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('getOctokit creates client independent from github', async () => {
|
|
||||||
const github = {rest: {issues: 'primary'}}
|
|
||||||
const getOctokit = jest.fn().mockReturnValue({rest: {issues: 'secondary'}})
|
|
||||||
|
|
||||||
const result = await callAsyncFunction(
|
|
||||||
{github, getOctokit} as any,
|
|
||||||
`
|
|
||||||
const secondary = getOctokit('other-token')
|
|
||||||
return {
|
|
||||||
primary: github.rest.issues,
|
|
||||||
secondary: secondary.rest.issues,
|
|
||||||
different: github !== secondary
|
|
||||||
}
|
|
||||||
`
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(result).toEqual({
|
|
||||||
primary: 'primary',
|
|
||||||
secondary: 'secondary',
|
|
||||||
different: true
|
|
||||||
})
|
|
||||||
expect(getOctokit).toHaveBeenCalledWith('other-token')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('getOctokit passes options through', async () => {
|
|
||||||
const getOctokit = jest.fn().mockReturnValue('client-with-opts')
|
|
||||||
|
|
||||||
const result = await callAsyncFunction(
|
|
||||||
{getOctokit} as any,
|
|
||||||
`return getOctokit('my-token', { baseUrl: 'https://ghes.example.com/api/v3' })`
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(getOctokit).toHaveBeenCalledWith('my-token', {
|
|
||||||
baseUrl: 'https://ghes.example.com/api/v3'
|
|
||||||
})
|
|
||||||
expect(result).toEqual('client-with-opts')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('getOctokit supports plugins', async () => {
|
|
||||||
const getOctokit = jest.fn().mockReturnValue('client-with-plugins')
|
|
||||||
|
|
||||||
const result = await callAsyncFunction(
|
|
||||||
{getOctokit} as any,
|
|
||||||
`return getOctokit('my-token', { previews: ['v3'] }, 'pluginA', 'pluginB')`
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(getOctokit).toHaveBeenCalledWith(
|
|
||||||
'my-token',
|
|
||||||
{previews: ['v3']},
|
|
||||||
'pluginA',
|
|
||||||
'pluginB'
|
|
||||||
)
|
|
||||||
expect(result).toEqual('client-with-plugins')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('multiple getOctokit calls produce independent clients', async () => {
|
|
||||||
const getOctokit = jest
|
|
||||||
.fn()
|
|
||||||
.mockReturnValueOnce({id: 'client-a'})
|
|
||||||
.mockReturnValueOnce({id: 'client-b'})
|
|
||||||
|
|
||||||
const result = await callAsyncFunction(
|
|
||||||
{getOctokit} as any,
|
|
||||||
`
|
|
||||||
const a = getOctokit('token-a')
|
|
||||||
const b = getOctokit('token-b')
|
|
||||||
return { a: a.id, b: b.id, different: a !== b }
|
|
||||||
`
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(getOctokit).toHaveBeenCalledTimes(2)
|
|
||||||
expect(getOctokit).toHaveBeenNthCalledWith(1, 'token-a')
|
|
||||||
expect(getOctokit).toHaveBeenNthCalledWith(2, 'token-b')
|
|
||||||
expect(result).toEqual({a: 'client-a', b: 'client-b', different: true})
|
|
||||||
})
|
|
||||||
|
|
||||||
test('throws on ReferenceError', async () => {
|
test('throws on ReferenceError', async () => {
|
||||||
expect.assertions(1)
|
expect.assertions(1)
|
||||||
|
|
||||||
|
|||||||
@@ -1,268 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
|
|
||||||
import {createConfiguredGetOctokit} from '../src/create-configured-getoctokit'
|
|
||||||
|
|
||||||
describe('createConfiguredGetOctokit', () => {
|
|
||||||
const mockRetryPlugin = jest.fn()
|
|
||||||
const mockRequestLogPlugin = jest.fn()
|
|
||||||
|
|
||||||
function makeMockGetOctokit() {
|
|
||||||
return jest.fn().mockReturnValue('mock-client')
|
|
||||||
}
|
|
||||||
|
|
||||||
test('passes token and merged defaults to underlying getOctokit', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const defaults = {
|
|
||||||
userAgent: 'actions/github-script actions_orchestration_id/abc',
|
|
||||||
retry: {enabled: true},
|
|
||||||
request: {retries: 3}
|
|
||||||
}
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(
|
|
||||||
raw as any,
|
|
||||||
defaults,
|
|
||||||
mockRetryPlugin,
|
|
||||||
mockRequestLogPlugin
|
|
||||||
)
|
|
||||||
wrapped('my-token' as any)
|
|
||||||
|
|
||||||
expect(raw).toHaveBeenCalledWith(
|
|
||||||
'my-token',
|
|
||||||
expect.objectContaining({
|
|
||||||
userAgent: 'actions/github-script actions_orchestration_id/abc',
|
|
||||||
retry: {enabled: true},
|
|
||||||
request: {retries: 3}
|
|
||||||
}),
|
|
||||||
mockRetryPlugin,
|
|
||||||
mockRequestLogPlugin
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('user options override top-level defaults', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const defaults = {
|
|
||||||
userAgent: 'default-agent',
|
|
||||||
previews: ['v3']
|
|
||||||
}
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(raw as any, defaults)
|
|
||||||
wrapped('tok' as any, {userAgent: 'custom-agent'} as any)
|
|
||||||
|
|
||||||
expect(raw).toHaveBeenCalledWith(
|
|
||||||
'tok',
|
|
||||||
expect.objectContaining({userAgent: 'custom-agent', previews: ['v3']})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('deep-merges request so partial overrides preserve retries', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const defaults = {
|
|
||||||
request: {retries: 3, agent: 'proxy-agent', fetch: 'proxy-fetch'}
|
|
||||||
}
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(raw as any, defaults)
|
|
||||||
wrapped('tok' as any, {request: {timeout: 5000}} as any)
|
|
||||||
|
|
||||||
expect(raw).toHaveBeenCalledWith(
|
|
||||||
'tok',
|
|
||||||
expect.objectContaining({
|
|
||||||
request: {
|
|
||||||
retries: 3,
|
|
||||||
agent: 'proxy-agent',
|
|
||||||
fetch: 'proxy-fetch',
|
|
||||||
timeout: 5000
|
|
||||||
}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('deep-merges retry so partial overrides preserve existing settings', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const defaults = {
|
|
||||||
retry: {enabled: true, retries: 3}
|
|
||||||
}
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(raw as any, defaults)
|
|
||||||
wrapped('tok' as any, {retry: {retries: 5}} as any)
|
|
||||||
|
|
||||||
expect(raw).toHaveBeenCalledWith(
|
|
||||||
'tok',
|
|
||||||
expect.objectContaining({
|
|
||||||
retry: {enabled: true, retries: 5}
|
|
||||||
})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('user can override request.retries explicitly', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const defaults = {request: {retries: 3}}
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(raw as any, defaults)
|
|
||||||
wrapped('tok' as any, {request: {retries: 0}} as any)
|
|
||||||
|
|
||||||
expect(raw).toHaveBeenCalledWith(
|
|
||||||
'tok',
|
|
||||||
expect.objectContaining({request: {retries: 0}})
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('user plugins are appended after default plugins', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const customPlugin = jest.fn()
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(
|
|
||||||
raw as any,
|
|
||||||
{},
|
|
||||||
mockRetryPlugin,
|
|
||||||
mockRequestLogPlugin
|
|
||||||
)
|
|
||||||
wrapped('tok' as any, {} as any, customPlugin as any)
|
|
||||||
|
|
||||||
expect(raw).toHaveBeenCalledWith(
|
|
||||||
'tok',
|
|
||||||
expect.any(Object),
|
|
||||||
mockRetryPlugin,
|
|
||||||
mockRequestLogPlugin,
|
|
||||||
customPlugin
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('duplicate plugins are deduplicated', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(
|
|
||||||
raw as any,
|
|
||||||
{},
|
|
||||||
mockRetryPlugin,
|
|
||||||
mockRequestLogPlugin
|
|
||||||
)
|
|
||||||
// User passes retry again — should not duplicate
|
|
||||||
wrapped('tok' as any, {} as any, mockRetryPlugin as any)
|
|
||||||
|
|
||||||
expect(raw).toHaveBeenCalledWith(
|
|
||||||
'tok',
|
|
||||||
expect.any(Object),
|
|
||||||
mockRetryPlugin,
|
|
||||||
mockRequestLogPlugin
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('applies defaults when no user options provided', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const defaults = {
|
|
||||||
userAgent: 'actions/github-script',
|
|
||||||
retry: {enabled: true},
|
|
||||||
request: {retries: 3}
|
|
||||||
}
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(
|
|
||||||
raw as any,
|
|
||||||
defaults,
|
|
||||||
mockRetryPlugin
|
|
||||||
)
|
|
||||||
wrapped('tok' as any)
|
|
||||||
|
|
||||||
expect(raw).toHaveBeenCalledWith(
|
|
||||||
'tok',
|
|
||||||
{
|
|
||||||
userAgent: 'actions/github-script',
|
|
||||||
retry: {enabled: true},
|
|
||||||
request: {retries: 3}
|
|
||||||
},
|
|
||||||
mockRetryPlugin
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('baseUrl: undefined from user does not clobber default', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const defaults = {baseUrl: 'https://ghes.example.com/api/v3'}
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(raw as any, defaults)
|
|
||||||
wrapped('tok' as any, {baseUrl: undefined} as any)
|
|
||||||
|
|
||||||
const calledOpts = raw.mock.calls[0][1]
|
|
||||||
expect(calledOpts.baseUrl).toBe('https://ghes.example.com/api/v3')
|
|
||||||
})
|
|
||||||
|
|
||||||
test('undefined values in nested request are stripped', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const defaults = {request: {retries: 3, agent: 'proxy'}}
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(raw as any, defaults)
|
|
||||||
wrapped('tok' as any, {request: {retries: undefined, timeout: 5000}} as any)
|
|
||||||
|
|
||||||
const calledOpts = raw.mock.calls[0][1]
|
|
||||||
expect(calledOpts.request).toEqual({
|
|
||||||
retries: 3,
|
|
||||||
agent: 'proxy',
|
|
||||||
timeout: 5000
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test('undefined values in nested retry are stripped', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const defaults = {retry: {enabled: true, retries: 3}}
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(raw as any, defaults)
|
|
||||||
wrapped('tok' as any, {retry: {enabled: undefined, retries: 5}} as any)
|
|
||||||
|
|
||||||
const calledOpts = raw.mock.calls[0][1]
|
|
||||||
expect(calledOpts.retry).toEqual({enabled: true, retries: 5})
|
|
||||||
})
|
|
||||||
|
|
||||||
test('each call creates an independent client', () => {
|
|
||||||
const raw = jest
|
|
||||||
.fn()
|
|
||||||
.mockReturnValueOnce('client-a')
|
|
||||||
.mockReturnValueOnce('client-b')
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(raw as any, {})
|
|
||||||
const a = wrapped('token-a' as any)
|
|
||||||
const b = wrapped('token-b' as any)
|
|
||||||
|
|
||||||
expect(a).toBe('client-a')
|
|
||||||
expect(b).toBe('client-b')
|
|
||||||
expect(raw).toHaveBeenCalledTimes(2)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('does not mutate defaultOptions between calls', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const defaults = {
|
|
||||||
request: {retries: 3},
|
|
||||||
retry: {enabled: true}
|
|
||||||
}
|
|
||||||
const originalDefaults = JSON.parse(JSON.stringify(defaults))
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(raw as any, defaults)
|
|
||||||
wrapped(
|
|
||||||
'tok' as any,
|
|
||||||
{request: {timeout: 5000}, retry: {retries: 10}} as any
|
|
||||||
)
|
|
||||||
wrapped('tok' as any, {request: {timeout: 9000}} as any)
|
|
||||||
|
|
||||||
expect(defaults).toEqual(originalDefaults)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('falsy-but-valid values are preserved, only undefined is stripped', () => {
|
|
||||||
const raw = makeMockGetOctokit()
|
|
||||||
const defaults = {baseUrl: 'https://ghes.example.com/api/v3'}
|
|
||||||
|
|
||||||
const wrapped = createConfiguredGetOctokit(raw as any, defaults)
|
|
||||||
wrapped(
|
|
||||||
'tok' as any,
|
|
||||||
{
|
|
||||||
log: null,
|
|
||||||
retries: 0,
|
|
||||||
debug: false,
|
|
||||||
userAgent: ''
|
|
||||||
} as any
|
|
||||||
)
|
|
||||||
|
|
||||||
const calledOpts = raw.mock.calls[0][1]
|
|
||||||
expect(calledOpts.log).toBeNull()
|
|
||||||
expect(calledOpts.retries).toBe(0)
|
|
||||||
expect(calledOpts.debug).toBe(false)
|
|
||||||
expect(calledOpts.userAgent).toBe('')
|
|
||||||
expect(calledOpts.baseUrl).toBe('https://ghes.example.com/api/v3')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
||||||
|
|
||||||
import {callAsyncFunction} from '../src/async-function'
|
|
||||||
|
|
||||||
// Create a mock getOctokit that returns Octokit-like objects.
|
|
||||||
// Real @actions/github integration is tested in the CI workflow
|
|
||||||
// (integration.yml test-get-octokit job). Here we verify the
|
|
||||||
// script context wiring — getOctokit is passed through and
|
|
||||||
// callable from user scripts.
|
|
||||||
function mockGetOctokit(token: string, options?: any) {
|
|
||||||
return {
|
|
||||||
_token: token,
|
|
||||||
_options: options,
|
|
||||||
rest: {
|
|
||||||
issues: {get: async () => ({data: {id: 1}})},
|
|
||||||
pulls: {get: async () => ({data: {id: 2}})}
|
|
||||||
},
|
|
||||||
graphql: async () => ({}),
|
|
||||||
request: async () => ({})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
describe('getOctokit integration via callAsyncFunction', () => {
|
|
||||||
test('getOctokit creates a functional client in script scope', async () => {
|
|
||||||
const result = await callAsyncFunction(
|
|
||||||
{getOctokit: mockGetOctokit} as any,
|
|
||||||
`
|
|
||||||
const client = getOctokit('fake-token-for-test')
|
|
||||||
return {
|
|
||||||
hasRest: typeof client.rest === 'object',
|
|
||||||
hasGraphql: typeof client.graphql === 'function',
|
|
||||||
hasRequest: typeof client.request === 'function',
|
|
||||||
hasIssues: typeof client.rest.issues === 'object',
|
|
||||||
hasPulls: typeof client.rest.pulls === 'object'
|
|
||||||
}
|
|
||||||
`
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(result).toEqual({
|
|
||||||
hasRest: true,
|
|
||||||
hasGraphql: true,
|
|
||||||
hasRequest: true,
|
|
||||||
hasIssues: true,
|
|
||||||
hasPulls: true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test('secondary client is independent from primary github client', async () => {
|
|
||||||
const primary = mockGetOctokit('primary-token')
|
|
||||||
|
|
||||||
const result = await callAsyncFunction(
|
|
||||||
{github: primary, getOctokit: mockGetOctokit} as any,
|
|
||||||
`
|
|
||||||
const secondary = getOctokit('secondary-token')
|
|
||||||
return {
|
|
||||||
bothHaveRest: typeof github.rest === 'object' && typeof secondary.rest === 'object',
|
|
||||||
areDistinct: github !== secondary
|
|
||||||
}
|
|
||||||
`
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(result).toEqual({
|
|
||||||
bothHaveRest: true,
|
|
||||||
areDistinct: true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
test('getOctokit accepts options for GHES base URL', async () => {
|
|
||||||
const result = await callAsyncFunction(
|
|
||||||
{getOctokit: mockGetOctokit} as any,
|
|
||||||
`
|
|
||||||
const client = getOctokit('fake-token', {
|
|
||||||
baseUrl: 'https://ghes.example.com/api/v3'
|
|
||||||
})
|
|
||||||
return typeof client.rest === 'object'
|
|
||||||
`
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(result).toBe(true)
|
|
||||||
})
|
|
||||||
|
|
||||||
test('multiple getOctokit calls produce independent clients with different tokens', async () => {
|
|
||||||
const result = await callAsyncFunction(
|
|
||||||
{getOctokit: mockGetOctokit} as any,
|
|
||||||
`
|
|
||||||
const clientA = getOctokit('token-a')
|
|
||||||
const clientB = getOctokit('token-b')
|
|
||||||
return {
|
|
||||||
aHasRest: typeof clientA.rest === 'object',
|
|
||||||
bHasRest: typeof clientB.rest === 'object',
|
|
||||||
areDistinct: clientA !== clientB
|
|
||||||
}
|
|
||||||
`
|
|
||||||
)
|
|
||||||
|
|
||||||
expect(result).toEqual({
|
|
||||||
aHasRest: true,
|
|
||||||
bHasRest: true,
|
|
||||||
areDistinct: true
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -36,5 +36,5 @@ outputs:
|
|||||||
result:
|
result:
|
||||||
description: The return value of the script, stringified with `JSON.stringify`
|
description: The return value of the script, stringified with `JSON.stringify`
|
||||||
runs:
|
runs:
|
||||||
using: node24
|
using: node20
|
||||||
main: dist/index.js
|
main: dist/index.js
|
||||||
|
|||||||
1481
dist/index.js
vendored
1481
dist/index.js
vendored
File diff suppressed because it is too large
Load Diff
154
package-lock.json
generated
154
package-lock.json
generated
@@ -1,11 +1,11 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/github-script",
|
"name": "github-script",
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@actions/github-script",
|
"name": "github-script",
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
"@octokit/core": "^5.0.1",
|
"@octokit/core": "^5.0.1",
|
||||||
"@octokit/plugin-request-log": "^4.0.0",
|
"@octokit/plugin-request-log": "^4.0.0",
|
||||||
"@octokit/plugin-retry": "^6.0.1",
|
"@octokit/plugin-retry": "^6.0.1",
|
||||||
"@types/node": "^24.1.0"
|
"@types/node": "^20.9.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.5",
|
"@types/jest": "^29.5.5",
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
"typescript": "^5.2.2"
|
"typescript": "^5.2.2"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=24"
|
"node": ">=20.0.0 <21.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@aashutoshrathi/word-wrap": {
|
"node_modules/@aashutoshrathi/word-wrap": {
|
||||||
@@ -1487,9 +1487,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@pkgr/utils/node_modules/cross-spawn": {
|
"node_modules/@pkgr/utils/node_modules/cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
@@ -1672,12 +1672,11 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"node_modules/@types/node": {
|
"node_modules/@types/node": {
|
||||||
"version": "24.1.0",
|
"version": "20.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz",
|
||||||
"integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==",
|
"integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==",
|
||||||
"license": "MIT",
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"undici-types": "~7.8.0"
|
"undici-types": "~5.26.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/semver": {
|
"node_modules/@types/semver": {
|
||||||
@@ -2282,12 +2281,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/braces": {
|
"node_modules/braces": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||||
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"fill-range": "^7.1.1"
|
"fill-range": "^7.0.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=8"
|
"node": ">=8"
|
||||||
@@ -2607,9 +2606,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/cross-spawn": {
|
"node_modules/cross-spawn": {
|
||||||
"version": "6.0.6",
|
"version": "6.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
|
||||||
"integrity": "sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw==",
|
"integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"nice-try": "^1.0.4",
|
"nice-try": "^1.0.4",
|
||||||
@@ -2703,9 +2702,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/default-browser/node_modules/cross-spawn": {
|
"node_modules/default-browser/node_modules/cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
@@ -3217,9 +3216,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/eslint/node_modules/cross-spawn": {
|
"node_modules/eslint/node_modules/cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
@@ -3475,9 +3474,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/execa/node_modules/cross-spawn": {
|
"node_modules/execa/node_modules/cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
@@ -3650,9 +3649,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fill-range": {
|
"node_modules/fill-range": {
|
||||||
"version": "7.1.1",
|
"version": "7.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||||
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"to-regex-range": "^5.0.1"
|
"to-regex-range": "^5.0.1"
|
||||||
@@ -5750,12 +5749,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/micromatch": {
|
"node_modules/micromatch": {
|
||||||
"version": "4.0.8",
|
"version": "4.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
|
||||||
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"braces": "^3.0.3",
|
"braces": "^3.0.2",
|
||||||
"picomatch": "^2.3.1"
|
"picomatch": "^2.3.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
@@ -7103,9 +7102,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "5.28.5",
|
"version": "5.26.3",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.26.3.tgz",
|
||||||
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
|
"integrity": "sha512-H7n2zmKEWgOllKkIUkLvFmsJQj062lSm3uA4EYApG8gLuiOM0/go9bIoC3HVaSnfg4xunowDE2i9p8drkXuvDw==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@fastify/busboy": "^2.0.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
},
|
},
|
||||||
@@ -7114,10 +7113,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici-types": {
|
"node_modules/undici-types": {
|
||||||
"version": "7.8.0",
|
"version": "5.26.5",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||||
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw==",
|
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
|
||||||
"license": "MIT"
|
|
||||||
},
|
},
|
||||||
"node_modules/universal-user-agent": {
|
"node_modules/universal-user-agent": {
|
||||||
"version": "6.0.0",
|
"version": "6.0.0",
|
||||||
@@ -8485,9 +8483,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-spawn": {
|
"cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
@@ -8654,11 +8652,11 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"@types/node": {
|
"@types/node": {
|
||||||
"version": "24.1.0",
|
"version": "20.9.0",
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-24.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-20.9.0.tgz",
|
||||||
"integrity": "sha512-ut5FthK5moxFKH2T1CUOC6ctR67rQRvvHdFLCD2Ql6KXmMuCrjsSsRI9UsLCm9M18BMwClv4pn327UvB7eeO1w==",
|
"integrity": "sha512-nekiGu2NDb1BcVofVcEKMIwzlx4NjHlcjhoxxKBNLtz15Y1z7MYf549DFvkHSId02Ax6kGwWntIBPC3l/JZcmw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"undici-types": "~7.8.0"
|
"undici-types": "~5.26.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"@types/semver": {
|
"@types/semver": {
|
||||||
@@ -9076,12 +9074,12 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"braces": {
|
"braces": {
|
||||||
"version": "3.0.3",
|
"version": "3.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||||
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"fill-range": "^7.1.1"
|
"fill-range": "^7.0.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"browserslist": {
|
"browserslist": {
|
||||||
@@ -9304,9 +9302,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cross-spawn": {
|
"cross-spawn": {
|
||||||
"version": "6.0.6",
|
"version": "6.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.5.tgz",
|
||||||
"integrity": "sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw==",
|
"integrity": "sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"nice-try": "^1.0.4",
|
"nice-try": "^1.0.4",
|
||||||
@@ -9357,9 +9355,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-spawn": {
|
"cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
@@ -9703,9 +9701,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"cross-spawn": {
|
"cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
@@ -9902,9 +9900,9 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cross-spawn": {
|
"cross-spawn": {
|
||||||
"version": "7.0.6",
|
"version": "7.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
|
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz",
|
||||||
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
|
"integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"path-key": "^3.1.0",
|
"path-key": "^3.1.0",
|
||||||
@@ -10047,9 +10045,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"fill-range": {
|
"fill-range": {
|
||||||
"version": "7.1.1",
|
"version": "7.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.1.1.tgz",
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||||
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"to-regex-range": "^5.0.1"
|
"to-regex-range": "^5.0.1"
|
||||||
@@ -11578,12 +11576,12 @@
|
|||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"micromatch": {
|
"micromatch": {
|
||||||
"version": "4.0.8",
|
"version": "4.0.5",
|
||||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.8.tgz",
|
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
|
||||||
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"braces": "^3.0.3",
|
"braces": "^3.0.2",
|
||||||
"picomatch": "^2.3.1"
|
"picomatch": "^2.3.1"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -12536,17 +12534,17 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"undici": {
|
"undici": {
|
||||||
"version": "5.28.5",
|
"version": "5.26.3",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-5.28.5.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-5.26.3.tgz",
|
||||||
"integrity": "sha512-zICwjrDrcrUE0pyyJc1I2QzBkLM8FINsgOrt6WjA+BgajVq9Nxu2PbFFXUrAggLfDXlZGZBVZYw7WNV5KiBiBA==",
|
"integrity": "sha512-H7n2zmKEWgOllKkIUkLvFmsJQj062lSm3uA4EYApG8gLuiOM0/go9bIoC3HVaSnfg4xunowDE2i9p8drkXuvDw==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"@fastify/busboy": "^2.0.0"
|
"@fastify/busboy": "^2.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"undici-types": {
|
"undici-types": {
|
||||||
"version": "7.8.0",
|
"version": "5.26.5",
|
||||||
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.8.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-5.26.5.tgz",
|
||||||
"integrity": "sha512-9UJ2xGDvQ43tYyVMpuHlsgApydB8ZKfVYTsLDhXkFL/6gfkp+U8xTGdh8pMJv1SpZna0zxG1DwsKZsreLbXBxw=="
|
"integrity": "sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA=="
|
||||||
},
|
},
|
||||||
"universal-user-agent": {
|
"universal-user-agent": {
|
||||||
"version": "6.0.0",
|
"version": "6.0.0",
|
||||||
|
|||||||
11
package.json
11
package.json
@@ -1,14 +1,15 @@
|
|||||||
{
|
{
|
||||||
"name": "@actions/github-script",
|
"name": "github-script",
|
||||||
"description": "A GitHub action for executing a simple script",
|
"description": "A GitHub action for executing a simple script",
|
||||||
"engines": {
|
|
||||||
"node": ">=24"
|
|
||||||
},
|
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"author": "GitHub",
|
"author": "GitHub",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "types/async-function.d.ts",
|
"types": "types/async-function.d.ts",
|
||||||
|
"private": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=20.0.0 <21.0.0"
|
||||||
|
},
|
||||||
"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 -t es5 --declaration --allowJs --emitDeclarationOnly --outDir types",
|
"build:types": "tsc src/async-function.ts -t es5 --declaration --allowJs --emitDeclarationOnly --outDir types",
|
||||||
@@ -46,7 +47,7 @@
|
|||||||
"@octokit/core": "^5.0.1",
|
"@octokit/core": "^5.0.1",
|
||||||
"@octokit/plugin-request-log": "^4.0.0",
|
"@octokit/plugin-request-log": "^4.0.0",
|
||||||
"@octokit/plugin-retry": "^6.0.1",
|
"@octokit/plugin-retry": "^6.0.1",
|
||||||
"@types/node": "^24.1.0"
|
"@types/node": "^20.9.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/jest": "^29.5.5",
|
"@types/jest": "^29.5.5",
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import * as core from '@actions/core'
|
|||||||
import * as exec from '@actions/exec'
|
import * as exec from '@actions/exec'
|
||||||
import {Context} from '@actions/github/lib/context'
|
import {Context} from '@actions/github/lib/context'
|
||||||
import {GitHub} from '@actions/github/lib/utils'
|
import {GitHub} from '@actions/github/lib/utils'
|
||||||
import {getOctokit} from '@actions/github'
|
|
||||||
import * as glob from '@actions/glob'
|
import * as glob from '@actions/glob'
|
||||||
import * as io from '@actions/io'
|
import * as io from '@actions/io'
|
||||||
|
|
||||||
@@ -12,8 +11,6 @@ export declare type AsyncFunctionArguments = {
|
|||||||
context: Context
|
context: Context
|
||||||
core: typeof core
|
core: typeof core
|
||||||
github: InstanceType<typeof GitHub>
|
github: InstanceType<typeof GitHub>
|
||||||
octokit: InstanceType<typeof GitHub>
|
|
||||||
getOctokit: typeof getOctokit
|
|
||||||
exec: typeof exec
|
exec: typeof exec
|
||||||
glob: typeof glob
|
glob: typeof glob
|
||||||
io: typeof io
|
io: typeof io
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
import {getOctokit} from '@actions/github'
|
|
||||||
import {GitHub} from '@actions/github/lib/utils'
|
|
||||||
import {OctokitOptions, OctokitPlugin} from '@octokit/core/dist-types/types'
|
|
||||||
|
|
||||||
type GetOctokit = typeof getOctokit
|
|
||||||
|
|
||||||
function stripUndefined<T extends Record<string, unknown>>(obj: T): Partial<T> {
|
|
||||||
const result: Partial<T> = {}
|
|
||||||
for (const [key, value] of Object.entries(obj)) {
|
|
||||||
if (value !== undefined) {
|
|
||||||
;(result as Record<string, unknown>)[key] = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result
|
|
||||||
}
|
|
||||||
|
|
||||||
export function createConfiguredGetOctokit(
|
|
||||||
rawGetOctokit: GetOctokit,
|
|
||||||
defaultOptions: OctokitOptions,
|
|
||||||
...defaultPlugins: OctokitPlugin[]
|
|
||||||
): GetOctokit {
|
|
||||||
return (
|
|
||||||
token: string,
|
|
||||||
options?: OctokitOptions,
|
|
||||||
...additionalPlugins: OctokitPlugin[]
|
|
||||||
): InstanceType<typeof GitHub> => {
|
|
||||||
const userOpts = stripUndefined(options || {})
|
|
||||||
const defaultRequest = defaultOptions.request
|
|
||||||
const userRequestRaw = userOpts.request as
|
|
||||||
| Record<string, unknown>
|
|
||||||
| undefined
|
|
||||||
const userRequest = userRequestRaw ? stripUndefined(userRequestRaw) : {}
|
|
||||||
const defaultRetry = defaultOptions.retry
|
|
||||||
const userRetryRaw = userOpts.retry as Record<string, unknown> | undefined
|
|
||||||
const userRetry = userRetryRaw ? stripUndefined(userRetryRaw) : {}
|
|
||||||
|
|
||||||
const merged: OctokitOptions = {
|
|
||||||
...defaultOptions,
|
|
||||||
...userOpts,
|
|
||||||
request: {...(defaultRequest || {}), ...userRequest},
|
|
||||||
retry: {...(defaultRetry || {}), ...userRetry}
|
|
||||||
}
|
|
||||||
|
|
||||||
const allPlugins = [...defaultPlugins]
|
|
||||||
for (const plugin of additionalPlugins) {
|
|
||||||
if (!allPlugins.includes(plugin)) {
|
|
||||||
allPlugins.push(plugin)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return rawGetOctokit(token, merged, ...allPlugins)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
32
src/main.ts
32
src/main.ts
@@ -8,7 +8,6 @@ import {requestLog} from '@octokit/plugin-request-log'
|
|||||||
import {retry} from '@octokit/plugin-retry'
|
import {retry} from '@octokit/plugin-retry'
|
||||||
import {RequestRequestOptions} from '@octokit/types'
|
import {RequestRequestOptions} from '@octokit/types'
|
||||||
import {callAsyncFunction} from './async-function'
|
import {callAsyncFunction} from './async-function'
|
||||||
import {createConfiguredGetOctokit} from './create-configured-getoctokit'
|
|
||||||
import {RetryOptions, getRetryOptions, parseNumberArray} from './retry-options'
|
import {RetryOptions, getRetryOptions, parseNumberArray} from './retry-options'
|
||||||
import {wrapRequire} from './wrap-require'
|
import {wrapRequire} from './wrap-require'
|
||||||
|
|
||||||
@@ -40,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
|
||||||
@@ -60,21 +56,12 @@ async function main(): Promise<void> {
|
|||||||
const github = getOctokit(token, opts, retry, requestLog)
|
const github = getOctokit(token, opts, retry, requestLog)
|
||||||
const script = core.getInput('script', {required: true})
|
const script = core.getInput('script', {required: true})
|
||||||
|
|
||||||
const configuredGetOctokit = createConfiguredGetOctokit(
|
|
||||||
getOctokit,
|
|
||||||
opts,
|
|
||||||
retry,
|
|
||||||
requestLog
|
|
||||||
)
|
|
||||||
|
|
||||||
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
|
// Using property/value shorthand on `require` (e.g. `{require}`) causes compilation errors.
|
||||||
const result = await callAsyncFunction(
|
const result = await callAsyncFunction(
|
||||||
{
|
{
|
||||||
require: wrapRequire,
|
require: wrapRequire,
|
||||||
__original_require__: __non_webpack_require__,
|
__original_require__: __non_webpack_require__,
|
||||||
github,
|
github,
|
||||||
octokit: github,
|
|
||||||
getOctokit: configuredGetOctokit,
|
|
||||||
context,
|
context,
|
||||||
core,
|
core,
|
||||||
exec,
|
exec,
|
||||||
@@ -108,20 +95,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}`
|
|
||||||
}
|
|
||||||
|
|||||||
3
types/async-function.d.ts
vendored
3
types/async-function.d.ts
vendored
@@ -3,15 +3,12 @@ import * as core from '@actions/core';
|
|||||||
import * as exec from '@actions/exec';
|
import * as exec from '@actions/exec';
|
||||||
import { Context } from '@actions/github/lib/context';
|
import { Context } from '@actions/github/lib/context';
|
||||||
import { GitHub } from '@actions/github/lib/utils';
|
import { GitHub } from '@actions/github/lib/utils';
|
||||||
import { getOctokit } from '@actions/github';
|
|
||||||
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: Context;
|
context: Context;
|
||||||
core: typeof core;
|
core: typeof core;
|
||||||
github: InstanceType<typeof GitHub>;
|
github: InstanceType<typeof GitHub>;
|
||||||
octokit: InstanceType<typeof GitHub>;
|
|
||||||
getOctokit: typeof getOctokit;
|
|
||||||
exec: typeof exec;
|
exec: typeof exec;
|
||||||
glob: typeof glob;
|
glob: typeof glob;
|
||||||
io: typeof io;
|
io: typeof io;
|
||||||
|
|||||||
Reference in New Issue
Block a user