forked from nipoppy/nipoppy
-
Notifications
You must be signed in to change notification settings - Fork 0
50 lines (41 loc) · 1.7 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
47
48
49
50
name: Check changed files
on:
pull_request:
branches:
- main
jobs:
check-changed-files:
runs-on: ubuntu-latest
env:
TEMPLATE_REPO: neurodatascience/nipoppy
PATH_CURRENT_REPO: repo_to_check
PATH_TEMPLATE_REPO: template_repo
if: github.repository_owner == 'neurodatascience' && github.event.repository.name != 'nipoppy' && github.head_ref != 'main-upstream'
steps:
- name: Checkout current repository
uses: actions/checkout@v3
with:
fetch-depth: 0
path: ${{ env.PATH_CURRENT_REPO }}
- name: Checkout template repository
uses: actions/checkout@v3
with:
repository: ${{ env.TEMPLATE_REPO }}
ref: main
path: ${{ env.PATH_TEMPLATE_REPO }}
- name: Check changed files
run: |
CHANGED_FILES=$(cd ${PATH_CURRENT_REPO}; 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 "${PATH_TEMPLATE_REPO}/${FILE}" ]; then
echo "::error file=${FILE}::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