Skip to content

Commit d846d6d

Browse files
committed
refactor: Enhance CI workflow to skip runs for draft PRs and non-code changes
1 parent e11c672 commit d846d6d

File tree

1 file changed

+44
-8
lines changed

1 file changed

+44
-8
lines changed

.github/workflows/main.yml

Lines changed: 44 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,56 @@ env:
1717
CI: true
1818

1919
jobs:
20-
# Skip CI for draft PRs and dependency updates
20+
# Skip CI for draft PRs or when changes are only in docs/examples/markdown
2121
should-skip:
2222
name: Check if CI should be skipped
2323
runs-on: ubuntu-latest
24-
if: github.event.pull_request.draft == false
2524
outputs:
26-
should_skip: ${{ steps.skip_check.outputs.should_skip }}
25+
should_skip: ${{ steps.check.outputs.should_skip }}
2726
steps:
28-
- id: skip_check
29-
uses: fkirc/skip-duplicate-actions@v5
27+
- name: Determine if CI should be skipped
28+
id: check
29+
run: |
30+
# Always run CI for push events
31+
if [[ "${{ github.event_name }}" == "push" ]]; then
32+
echo "should_skip=false" >> $GITHUB_OUTPUT
33+
echo "✅ Running CI: Push event"
34+
exit 0
35+
fi
36+
37+
# Skip CI for draft PRs
38+
if [[ "${{ github.event.pull_request.draft }}" == "true" ]]; then
39+
echo "should_skip=true" >> $GITHUB_OUTPUT
40+
echo "⏭️ Skipping CI: Draft PR"
41+
exit 0
42+
fi
43+
44+
echo "should_skip=false" >> $GITHUB_OUTPUT
45+
echo "✅ Running CI: Ready for review PR"
46+
47+
- name: Checkout code to check file changes
48+
if: github.event_name == 'pull_request' && !github.event.pull_request.draft
49+
uses: actions/checkout@v4
3050
with:
31-
concurrent_skipping: "same_content_newer"
32-
skip_after_successful_duplicate: "true"
33-
paths_ignore: '["**/*.md", "docs/**", "examples/**", "*.md"]'
51+
fetch-depth: 0
52+
53+
- name: Check if only docs/examples/markdown changed
54+
if: github.event_name == 'pull_request' && !github.event.pull_request.draft
55+
run: |
56+
# Get changed files between base and head
57+
git diff --name-only origin/${{ github.base_ref }}...HEAD > changed_files.txt
58+
59+
echo "📝 Changed files:"
60+
cat changed_files.txt
61+
62+
# Check if any non-docs/examples/markdown files changed
63+
if grep -v -E '^(docs/|examples/|.*\.md$)' changed_files.txt; then
64+
echo "✅ Code files changed - running CI"
65+
echo "should_skip=false" >> $GITHUB_OUTPUT
66+
else
67+
echo "⏭️ Only docs/examples/markdown files changed - skipping CI"
68+
echo "should_skip=true" >> $GITHUB_OUTPUT
69+
fi
3470
3571
test:
3672
needs: should-skip

0 commit comments

Comments
 (0)