Skip to content

Test check_changed_files.yml CI workflow #8

Test check_changed_files.yml CI workflow

Test check_changed_files.yml CI workflow #8

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