-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: add workflow to check if versioning pr exists
- Loading branch information
1 parent
d45e7f7
commit 3e3522e
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
name: versioning_pr_exists | ||
|
||
on: | ||
pull_request: | ||
types: [opened, edited, reopened, synchronize] | ||
|
||
jobs: | ||
check-version-pr: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: "14" | ||
|
||
- name: Check if PR with title chore(version) exists | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.PAT }} | ||
script: | | ||
const { data: pullRequests } = await github.rest.pulls.list({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
state: 'open', | ||
per_page: 100 | ||
}); | ||
const existingPR = pullRequests.find(pr => pr.title === 'chore(version): bump version and update changelog'); | ||
if (existingPR) { | ||
core.setFailed(`Version bump pull request exists. Please merge that pr first to pass the check.: #${existingPR.number}`); | ||
} else { | ||
console.log("No version bump pull request found."); | ||
} | ||
- name: Fail if PR exists | ||
if: steps.check-pr.outputs.exists == 'true' | ||
run: | | ||
echo "Version bump pull request exists. Please merge that pr first to pass the check." | ||
exit 1 |