-
Notifications
You must be signed in to change notification settings - Fork 0
46 lines (37 loc) · 1.45 KB
/
check_changed_files.yml
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
40
41
42
43
44
45
46
name: Check changed files
on:
pull_request:
branches:
- main
jobs:
check-changed-files:
runs-on: ubuntu-latest
if: github.repository_owner == 'neurodatascience' && github.event.repository.name != 'testpoppy'
steps:
- name: Checkout current repository
uses: actions/checkout@v3
with:
fetch-depth: 0
path: repo_to_check
- name: Checkout template repository
uses: actions/checkout@v3
with:
repository: neurodatascience/testpoppy
ref: main
path: template_repo
- name: Check changed files
run: |
CHANGED_FILES=$(cd repo_to_check; git diff-tree --no-commit-id --name-only -r ${{ github.event.pull_request.head.sha }} ${{ github.event.pull_request.base.sha }})
echo -e "Checking changed files:\n${CHANGED_FILES}"
COUNT="0"
for FILE in ${CHANGED_FILES}; do
if [ -f "template_repo/${FILE}" ]; then
echo "::error::File exists in the template repository: ${FILE}"
COUNT=$((COUNT+1))
fi
done
if [ ${COUNT} -gt 0 ]
then
echo "This PR modifies ${COUNT} files that also exist in the template repository."
exit 1
fi