-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (36 loc) · 1.18 KB
/
Copy path_detect-code-changes.yml
File metadata and controls
39 lines (36 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
name: Detect code changes
# Reusable workflow that reports whether a pull request touches anything
# other than README.md / docs/**. Callers gate their real jobs on the
# `code` output so docs-only PRs skip CI work while still reporting success.
on:
workflow_call:
outputs:
code:
description: "true if non-docs files changed (or not a pull request)"
value: ${{ jobs.detect.outputs.code }}
jobs:
detect:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
code: ${{ steps.filter.outputs.code }}
steps:
- name: Checkout
uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: Detect non-docs changes
id: filter
run: |
if [ "${{ github.event_name }}" != "pull_request" ]; then
echo "code=true" >> "$GITHUB_OUTPUT"
exit 0
fi
if git diff --name-only \
"${{ github.event.pull_request.base.sha }}...${{ github.event.pull_request.head.sha }}" \
| grep -qvE '^(README\.md$|docs/)'; then
echo "code=true" >> "$GITHUB_OUTPUT"
else
echo "code=false" >> "$GITHUB_OUTPUT"
fi