Skip to content

Commit 3a2844b

Browse files
authored
Merge pull request #700 from actions/salmanmkc/expose-getoctokit + prepare release for v9
feat!: add getOctokit to script context, upgrade @actions/github v9, @octokit/core v7, and related packages
2 parents afff112 + ca10bbd commit 3a2844b

35 files changed

+58611
-28916
lines changed

.github/workflows/integration.yml

Lines changed: 40 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ jobs:
4242
result-encoding: string
4343
- run: |
4444
echo "- Validating relative require output"
45-
if [[ "${{steps.relative-require.outputs.result}}" != "@actions/github-script" ]]; then
45+
expected="@actions/github-script"
46+
if [[ "${{steps.relative-require.outputs.result}}" != "$expected" ]]; then
4647
echo $'::error::\u274C' "Expected '$expected', got ${{steps.relative-require.outputs.result}}"
4748
exit 1
4849
fi
@@ -154,22 +155,54 @@ jobs:
154155
return endpoint({}).headers['user-agent']
155156
result-encoding: string
156157
- run: |
158+
# User-agent format: <prefix> [actions_orchestration_id/<id>] octokit-core.js/<version> ...
159+
# When ACTIONS_ORCHESTRATION_ID is set, the orchestration ID is inserted after the prefix
157160
echo "- Validating user-agent default"
158161
ua="${{steps.user-agent-default.outputs.result}}"
159-
if [[ "$ua" != "actions/github-script octokit-core.js/"* ]] && [[ "$ua" != "actions/github-script actions_orchestration_id/"* ]]; then
160-
echo $'::error::\u274C' "Expected user-agent to start with 'actions/github-script', got $ua"
162+
if [[ "$ua" != "actions/github-script"* ]] || [[ "$ua" != *"octokit-core.js/"* ]]; then
163+
echo $'::error::\u274C' "Expected user-agent to start with 'actions/github-script' and contain 'octokit-core.js/', got $ua"
161164
exit 1
162165
fi
163166
echo "- Validating user-agent set to a value"
164167
ua="${{steps.user-agent-set.outputs.result}}"
165-
if [[ "$ua" != "foobar octokit-core.js/"* ]] && [[ "$ua" != "foobar actions_orchestration_id/"* ]]; then
166-
echo $'::error::\u274C' "Expected user-agent to start with 'foobar', got $ua"
168+
if [[ "$ua" != "foobar"* ]] || [[ "$ua" != *"octokit-core.js/"* ]]; then
169+
echo $'::error::\u274C' "Expected user-agent to start with 'foobar' and contain 'octokit-core.js/', got $ua"
167170
exit 1
168171
fi
169172
echo "- Validating user-agent set to an empty string"
170173
ua="${{steps.user-agent-empty.outputs.result}}"
171-
if [[ "$ua" != "actions/github-script octokit-core.js/"* ]] && [[ "$ua" != "actions/github-script actions_orchestration_id/"* ]]; then
172-
echo $'::error::\u274C' "Expected user-agent to start with 'actions/github-script', got $ua"
174+
if [[ "$ua" != "actions/github-script"* ]] || [[ "$ua" != *"octokit-core.js/"* ]]; then
175+
echo $'::error::\u274C' "Expected user-agent to start with 'actions/github-script' and contain 'octokit-core.js/', got $ua"
176+
exit 1
177+
fi
178+
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY
179+
180+
test-get-octokit:
181+
name: 'Integration test: getOctokit with token'
182+
runs-on: ubuntu-latest
183+
steps:
184+
- uses: actions/checkout@v4
185+
- uses: ./.github/actions/install-dependencies
186+
- id: secondary-client
187+
name: Create a second client with getOctokit
188+
uses: ./
189+
env:
190+
APP_TOKEN: ${{ github.token }}
191+
with:
192+
script: |
193+
const appOctokit = getOctokit(process.env.APP_TOKEN)
194+
const {data} = await appOctokit.rest.repos.get({
195+
owner: context.repo.owner,
196+
repo: context.repo.repo
197+
})
198+
199+
return `${appOctokit !== github}:${data.full_name}`
200+
result-encoding: string
201+
- run: |
202+
echo "- Validating secondary client output"
203+
expected="true:${{ github.repository }}"
204+
if [[ "${{steps.secondary-client.outputs.result}}" != "$expected" ]]; then
205+
echo $'::error::\u274C' "Expected '$expected', got ${{steps.secondary-client.outputs.result}}"
173206
exit 1
174207
fi
175208
echo $'\u2705 Test passed' | tee -a $GITHUB_STEP_SUMMARY

.licenses/npm/@actions/github.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@actions/http-client-2.2.0.dep.yml

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@actions/http-client-3.0.2.dep.yml

Lines changed: 32 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@octokit/auth-token.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@octokit/core.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@octokit/endpoint.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@octokit/graphql.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@octokit/openapi-types.dep.yml

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.licenses/npm/@octokit/plugin-paginate-rest.dep.yml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)