Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 33 additions & 33 deletions .github/workflows/build-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: Check out repository
uses: actions/checkout@v6
- uses: actions/setup-node@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: '24'
- name: Build with esbuild
run: |
npm install
npm run build
- name: Archive dist
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: build
path: dist
Expand All @@ -30,9 +30,9 @@ jobs:
name: "echo-1-test [trigger|by workflow name]"
steps:
- name: Check out repository
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Download dist
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: dist
Expand All @@ -50,9 +50,9 @@ jobs:
name: "echo-2-test [trigger|by workflow filename]"
steps:
- name: Check out repository
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Download dist
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: dist
Expand All @@ -69,9 +69,9 @@ jobs:
name: "echo-path-test [trigger|by workflow full path]"
steps:
- name: Check out repository
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Download dist
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: dist
Expand All @@ -89,9 +89,9 @@ jobs:
name: "long-running-test [trigger+wait|by workflow filename|shoud succeed]"
steps:
- name: Check out repository
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Download dist
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: dist
Expand All @@ -106,11 +106,11 @@ jobs:
display-workflow-run-url-interval: 10s
display-workflow-run-url-timeout: 5m
continue-on-error: true
- uses: nick-invision/assert-action@v3.0.0
- uses: nick-invision/assert-action@22dd2a66ef733fe92022d3704183ac007463eecb # v3.0.0
with:
expected: success
actual: ${{ steps.long-running-workflow.outputs.workflow-conclusion }}
- uses: nick-invision/assert-action@v3.0.0
- uses: nick-invision/assert-action@22dd2a66ef733fe92022d3704183ac007463eecb # v3.0.0
with:
expected: success
actual: ${{ steps.long-running-workflow.outcome }}
Expand All @@ -121,9 +121,9 @@ jobs:
name: "failing-test [trigger+wait|by workflow filename|should report failure]"
steps:
- name: Check out repository
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Download dist
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: dist
Expand All @@ -139,11 +139,11 @@ jobs:
display-workflow-run-url-timeout: 60s
continue-on-error: true
- run: echo "worflow-conclusion=${{ steps.failing-workflow.outputs.workflow-conclusion }}"
- uses: nick-invision/assert-action@v3.0.0
- uses: nick-invision/assert-action@22dd2a66ef733fe92022d3704183ac007463eecb # v3.0.0
with:
expected: failure
actual: ${{ steps.failing-workflow.outputs.workflow-conclusion }}
- uses: nick-invision/assert-action@v3.0.0
- uses: nick-invision/assert-action@22dd2a66ef733fe92022d3704183ac007463eecb # v3.0.0
with:
expected: failure
actual: ${{ steps.failing-workflow.outcome }}
Expand All @@ -154,9 +154,9 @@ jobs:
name: "timeout-test [trigger+wait|by workflow filename|should report timed_out]"
steps:
- name: Check out repository
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Download dist
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: dist
Expand All @@ -171,11 +171,11 @@ jobs:
display-workflow-run-url-interval: 10s
display-workflow-run-url-timeout: 30s
continue-on-error: true
- uses: nick-invision/assert-action@v3.0.0
- uses: nick-invision/assert-action@22dd2a66ef733fe92022d3704183ac007463eecb # v3.0.0
with:
expected: timed_out
actual: ${{ steps.timeout-workflow.outputs.workflow-conclusion }}
- uses: nick-invision/assert-action@v3.0.0
- uses: nick-invision/assert-action@22dd2a66ef733fe92022d3704183ac007463eecb # v3.0.0
with:
expected: failure
actual: ${{ steps.timeout-workflow.outcome }}
Expand All @@ -186,9 +186,9 @@ jobs:
name: "print-workflow-logs-test [trigger+wait|by workflow filename|print logs|should report timed_out]"
steps:
- name: Check out repository
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Download dist
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: dist
Expand All @@ -204,11 +204,11 @@ jobs:
display-workflow-run-url-timeout: 120s
workflow-logs: print
continue-on-error: true
- uses: nick-invision/assert-action@v3.0.0
- uses: nick-invision/assert-action@22dd2a66ef733fe92022d3704183ac007463eecb # v3.0.0
with:
expected: timed_out
actual: ${{ steps.print-workflow-logs.outputs.workflow-conclusion }}
- uses: nick-invision/assert-action@v3.0.0
- uses: nick-invision/assert-action@22dd2a66ef733fe92022d3704183ac007463eecb # v3.0.0
with:
expected: failure
actual: ${{ steps.print-workflow-logs.outcome }}
Expand Down Expand Up @@ -236,9 +236,9 @@ jobs:
RUN_NAME: ${{ github.repository }}/actions/runs/${{ github.run_id }}/envs/${{ matrix.environment }}
steps:
- name: Check out repository
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Download dist
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: dist
Expand All @@ -260,15 +260,15 @@ jobs:
"environment": "${{ matrix.environment }}"
}
continue-on-error: true
- uses: nick-invision/assert-action@v3.0.0
- uses: nick-invision/assert-action@22dd2a66ef733fe92022d3704183ac007463eecb # v3.0.0
with:
expected: success
actual: ${{ steps.named-run-workflow.outputs.workflow-conclusion }}
- uses: nick-invision/assert-action@v3.0.0
- uses: nick-invision/assert-action@22dd2a66ef733fe92022d3704183ac007463eecb # v3.0.0
with:
expected: success
actual: ${{ steps.named-run-workflow.outcome }}
- uses: nick-invision/assert-action@v3.0.0
- uses: nick-invision/assert-action@22dd2a66ef733fe92022d3704183ac007463eecb # v3.0.0
env:
EXPECTED_LOG_MESSAGE: "### Env: ${{ matrix.environment }} ###"
with:
Expand All @@ -288,14 +288,14 @@ jobs:
runs-on: ubuntu-24.04
steps:
- name: Check out repository
uses: actions/checkout@v6
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
- name: Download dist
uses: actions/download-artifact@v8
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: build
path: dist
- name: Update repo with build
uses: mikeal/publish-to-github-action@master
uses: mikeal/publish-to-github-action@e5a27bbb5174edae8930d2250fc98a3a32478f81 # master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

2 changes: 1 addition & 1 deletion .github/workflows/retrieve-logs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
more-real-example:
runs-on: ubuntu-24.04
steps:
- uses: actions/setup-node@v6
- uses: actions/setup-node@249970729cb0ef3589644e2896645e5dc5ba9c38 # v6.5.0
with:
node-version: '24'
- name: Some command with npx
Expand Down
18 changes: 12 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25183,8 +25183,7 @@ var WorkflowHandler = class {
`POST /repos/${this.owner}/${this.repo}/actions/workflows/${encodedWorkflowId}/dispatches`,
{
ref: this.ref,
inputs,
return_run_details: true
inputs
}
);
debug2("Workflow Dispatch", dispatchResp);
Expand Down Expand Up @@ -25483,11 +25482,18 @@ async function handleLogs(octokit, args, workflowHandler) {
error(`Failed to handle logs of triggered workflow. Cause: ${e}`);
}
}
var API_VERSION = "2026-03-10";
function withApiVersion(octokit) {
octokit.hook.before("request", (options) => {
options.headers["x-github-api-version"] = API_VERSION;
});
return octokit;
}
async function setupOctokit(token, appId, appPrivateKey) {
if (token) {
return new Octokit2({
return withApiVersion(new Octokit2({
auth: token
});
}));
}
return setupGitHubAppOctokit(appId, appPrivateKey);
}
Expand All @@ -25499,10 +25505,10 @@ async function setupGitHubAppOctokitClient(appId, privateKey, installationId) {
if (installationId) {
auth6.installationId = installationId;
}
return new Octokit2({
return withApiVersion(new Octokit2({
authStrategy: createAppAuth,
auth: auth6
});
}));
}
async function setupGitHubAppOctokit(appId, privateKey) {
const octokit = await setupGitHubAppOctokitClient(appId, privateKey);
Expand Down
21 changes: 16 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,22 @@ async function handleLogs(octokit: Octokit, args: any, workflowHandler: Workflow
}
}

// REST API version sent on every request. Without it GitHub uses 2022-11-28, under which
// the dispatch endpoint is deprecated (removal scheduled 2028-03-10).
const API_VERSION = '2026-03-10'

function withApiVersion(octokit: Octokit): Octokit {
octokit.hook.before('request', (options) => {
options.headers['x-github-api-version'] = API_VERSION
})
return octokit
}

async function setupOctokit(token: string, appId: string, appPrivateKey: string):Promise<Octokit> {
if(token) {
return new Octokit({
return withApiVersion(new Octokit({
auth: token
})
}))
}

return setupGitHubAppOctokit(appId, appPrivateKey)
Expand All @@ -90,10 +101,10 @@ async function setupGitHubAppOctokitClient(appId: string, privateKey: string, in
auth.installationId = installationId
}

return new Octokit({
return withApiVersion(new Octokit({
authStrategy: createAppAuth,
auth,
})
}))
}

async function setupGitHubAppOctokit(appId: string, privateKey: string):Promise<Octokit> {
Expand Down Expand Up @@ -124,7 +135,7 @@ async function run(): Promise<void> {
core.info('Workflow triggered 🚀')

if (args.displayWorkflowUrl) {
// Use the immediate URL from return_run_details if available, otherwise poll
// Use the URL returned by the dispatch call if available, otherwise poll
let url = workflowHandler.getWorkflowRunUrl()
if (!url) {
url = await getFollowUrl(workflowHandler, args.displayWorkflowUrlInterval, args.displayWorkflowUrlTimeout)
Expand Down
3 changes: 1 addition & 2 deletions src/workflow-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ export class WorkflowHandler {
{
ref: this.ref,
inputs,
return_run_details: true,
}
)
debug('Workflow Dispatch', dispatchResp)

// If the API returned run details, cache the run ID and URL immediately
// API version 2026-03-10 always returns the run details; cache them so no run lookup is needed
if (dispatchResp.data?.workflow_run_id) {
this.workflowRunId = dispatchResp.data.workflow_run_id
this.workflowRunUrl = dispatchResp.data.html_url
Expand Down
Loading