Ref: Skip CI for commits without code changes #20
Workflow file for this run
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
name: Skip CI | |
on: | |
pull_request: | |
jobs: | |
check-ci: | |
runs-on: ubuntu-latest | |
outputs: | |
skip_ci: ${{ steps.check-diff.outputs.skip_ci }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Check diff from Pull Request | |
id: check-diff | |
run: | | |
skipList=(".github/codeowners") | |
# Ignores changelog.md, readme.md,... | |
fileChangesArray=($(git diff --name-only origin/${{ github.base_ref }}..origin/${{ github.head_ref }} | grep -v '\.md$')) | |
echo ${fileChangesArray} | |
git diff --name-only origin/${{ github.base_ref }}..origin/${{ github.head_ref }} | |
for item in "${fileChangesArray[@]}" | |
do | |
if [[ ! " ${skipList[@]} " =~ " ${item} " ]]; then | |
#found an item that doesn't belong to the skip list. | |
exit 0 | |
fi | |
done | |
echo "skip_ci=true" >> $GITHUB_OUTPUT | |
- name: test | |
run: echo ${{ env.skip_ci }} |