-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathaction.yml
More file actions
34 lines (33 loc) · 1.3 KB
/
action.yml
File metadata and controls
34 lines (33 loc) · 1.3 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
name: 'Check Docs Only Changes'
description: 'Check if only documentation files were changed'
outputs:
docs-only:
description: "True if only documentation files were changed"
value: ${{ steps.check.outputs.docs_only }}
runs:
using: "composite"
steps:
- name: Check if only docs changed
id: check
shell: bash
run: |
# Determine the base SHA for comparison
if [ "${{ github.event_name }}" = "pull_request" ]; then
# For PRs, compare against the base branch
BASE_SHA="${{ github.event.pull_request.base.sha }}"
FILES_CHANGED=$(git diff --name-only "${BASE_SHA}"...HEAD)
else
# For pushes, compare with previous commit
FILES_CHANGED=$(git diff --name-only HEAD~1...HEAD 2>/dev/null || echo "")
fi
# Check if all changed files are in docs/ directory
if [ -z "$FILES_CHANGED" ]; then
echo "docs_only=false" >> $GITHUB_OUTPUT
echo "No files changed"
elif echo "$FILES_CHANGED" | grep -vE '^docs/' > /dev/null; then
echo "docs_only=false" >> $GITHUB_OUTPUT
echo "Non-documentation files changed"
else
echo "docs_only=true" >> $GITHUB_OUTPUT
echo "All changes are in docs/ folder, checks will pass automatically"
fi