Update to match neurodatascience/nipoppy:main #33
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: 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 |