Skip to content

Commit

Permalink
Use commit as head_sha to reduce number of API calls (#227)
Browse files Browse the repository at this point in the history
* Use `commit` as `head_sha` to reduce number of API calls

Less results -> less pagination -> less API calls.
Maybe a bit faster even.

https://octokit.github.io/rest.js/v19#actions-list-workflow-runs

* Add CI check for commit

* Use event head_sha
  • Loading branch information
lukasz-mitka committed Feb 21, 2023
1 parent b59d8c6 commit 5e780fc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/download.yml
Expand Up @@ -58,6 +58,21 @@ jobs:
pr: ${{github.event.pull_request.number}}
- name: Test
run: cat artifact/sha | grep $GITHUB_SHA
download-commit:
runs-on: ubuntu-latest
needs: wait
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Download
uses: ./
with:
workflow: upload.yml
name: artifact
path: artifact
commit: ${{ github.event.workflow_run.head_sha }}
- name: Test
run: cat artifact/sha | grep $GITHUB_SHA
download-multiple:
runs-on: ubuntu-latest
needs: wait
Expand Down
4 changes: 1 addition & 3 deletions main.js
Expand Up @@ -109,12 +109,10 @@ async function main() {
workflow_id: workflow,
...(branch ? { branch } : {}),
...(event ? { event } : {}),
...(commit ? { head_sha: commit } : {}),
}
)) {
for (const run of runs.data) {
if (commit && run.head_sha != commit) {
continue
}
if (runNumber && run.run_number != runNumber) {
continue
}
Expand Down

0 comments on commit 5e780fc

Please sign in to comment.