Skip to content

Commit 28da7c7

Browse files
committed
Add PR Dependency check workflow
1 parent c188fe5 commit 28da7c7

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Check for Dependencies in PR
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened, edited, labeled, unlabeled, synchronize]
6+
7+
jobs:
8+
check-dependency:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Check PR description for "depends on"
12+
# Use a script to check the PR body and all commit messages
13+
run: |
14+
PR_BODY=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.body)
15+
if echo "$PR_BODY" | grep -qi "^depends on"; then
16+
echo "::error::PR description contains 'depends on'. Merging is blocked."
17+
exit 1
18+
fi
19+
if echo "$PR_BODY" | grep -qi "^requires"; then
20+
echo "::error::PR description contains 'requires'. Merging is blocked."
21+
exit 1
22+
fi
23+
24+
# Optional: Check all commit messages in the PR
25+
# Note: This requires the 'pull-requests: read' permission
26+
# If you don't need this, you can remove the following lines
27+
echo "Checking commit messages..."
28+
COMMIT_MESSAGES=$(cat $GITHUB_EVENT_PATH | jq -r .pull_request.commits_url | xargs curl -s | jq -r '.[].commit.message')
29+
if echo "$COMMIT_MESSAGES" | grep -qi "depends on"; then
30+
echo "::error::A commit message contains 'depends on'. Merging is blocked."
31+
exit 1
32+
fi
33+
if echo "$COMMIT_MESSAGES" | grep -qi "^requires"; then
34+
echo "::error::A commit message contains 'requires'. Merging is blocked."
35+
exit 1
36+
fi
37+
38+
env:
39+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/pull_request.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
types: [opened, reopened, synchronize]
99

1010
jobs:
11+
pr_dependency_check:
12+
name: PR Dependency Check
13+
uses: ./.github/workflows/check_pr_dependency.yml
14+
1115
tests_with_docker_embedded_swift:
1216
name: Test Embedded Swift SDKs
1317
uses: ./.github/workflows/swift_package_test.yml

0 commit comments

Comments
 (0)