Bump actions/checkout from 2 to 4 #9
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: PR cleanliness | |
on: [pull_request] | |
jobs: | |
pr_clean: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: Check for added-and-deleted files | |
run: | | |
git fetch --quiet origin "$GITHUB_BASE_REF" | |
base="$(git merge-base "origin/$GITHUB_BASE_REF" 'HEAD^2')" | |
ad="$(git log "$base..HEAD^2" --pretty=tformat: --name-status --diff-filter=AD | | |
cut --fields 2 | sort | uniq --repeated)" | |
if [[ -n "$ad" ]]; then | |
printf 'The following files were both added and deleted in this PR:\n%s\n' "$ad" | |
exit 1 | |
fi | |
- name: Check for added-and-modified images | |
run: | | |
git fetch --quiet origin "$GITHUB_BASE_REF" | |
base="$(git merge-base "origin/$GITHUB_BASE_REF" 'HEAD^2')" | |
am="$(git log "$base..HEAD^2" --pretty=tformat: --name-status --diff-filter=AM | | |
cut --fields 2 | sort | uniq --repeated | | |
grep -E '\.(png|pdf|ps|eps|svg)' || true)" | |
if [[ -n "$am" ]]; then | |
printf 'The following images were both added and modified in this PR:\n%s\n' "$am" | |
exit 1 | |
fi | |
- name: Check for invalid backports to -doc branches | |
if: endsWith(github.base_ref, '-doc') | |
run: | | |
git fetch --quiet origin "$GITHUB_BASE_REF" | |
base="$(git merge-base "origin/$GITHUB_BASE_REF" 'HEAD^2')" | |
lib="$(git log "$base..HEAD^2" --pretty=tformat: --name-status -- lib src | | |
cut --fields 2 | sort || true)" | |
if [[ -n "$lib" ]]; then | |
printf 'Changes to the following files have no effect and should not be backported:\n%s\n' "$lib" | |
exit 1 | |
fi |