Skip to content

Commit 8d2b95c

Browse files
committed
wip
1 parent cf75fd7 commit 8d2b95c

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

.github/workflows/check_pr.yml

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

0 commit comments

Comments
 (0)