Skip to content

Commit 1a84534

Browse files
committed
Add workflow check
1 parent 28e4c2a commit 1a84534

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

.github/workflows/_check.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
on:
2+
workflow_call:
3+
outputs:
4+
branch-pr:
5+
description: The PR number if the branch is in one
6+
value: ${{ jobs.pr.outputs.branch-pr }}
7+
8+
jobs:
9+
pr:
10+
runs-on: "ubuntu-latest"
11+
outputs:
12+
branch-pr: ${{ steps.script.outputs.result }}
13+
steps:
14+
- uses: actions/github-script@v7
15+
id: script
16+
if: github.event_name == 'push'
17+
with:
18+
script: |
19+
const prs = await github.rest.pulls.list({
20+
owner: context.repo.owner,
21+
repo: context.repo.repo,
22+
head: context.repo.owner + ':${{ github.ref_name }}'
23+
})
24+
if (prs.data.length) {
25+
console.log(`::notice ::Skipping CI on branch push as it is already run in PR #${prs.data[0]["number"]}`)
26+
return prs.data[0]["number"]
27+
}

0 commit comments

Comments
 (0)