Skip to content

Add script to ignore files inside .git #21

Add script to ignore files inside .git

Add script to ignore files inside .git #21

name: Check diff between template and current state
on: [push]
jobs:
generate-diff:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
node-version:
- 18.x
steps:
- name: Checkout source branch
uses: actions/checkout@v4
with:
repository: Informatievlaanderen/OSLOthema-template
ref: standaardenregister
path: source
- name: Clone other repository
uses: actions/checkout@v4
with:
# Dynamic reference to the active repository so that it works immediately when creating a new thema repo
# repository: ${{ github.repository }}
repository: Informatievlaanderen/OSLOthema-voorwaarden-dienstverlening
ref: standaardenregister
path:
target
# Extra step to debug the file structure
- name: List file structure of source dir
shell: bash
run: |
ls source
- name: List file structure of target dir
shell: bash
run: |
ls target
- name: Create diff
shell: bash
run: |
# fallback needed because diff returns 1 when there are differences which causes the workflow to fail
identical_files=""
different_files=""
for file in $(find source -type f | grep -v ".git"); do
target_file=${file/source/target}
if [ -f "$target_file" ]; then
diff_output=$(diff -q "$file" "$target_file" || true)
if [[ $diff_output == *"differ"* ]]; then
different_files+="$file\n"
else
identical_files+="$file\n"
fi
fi
done
echo -e "$identical_files" > identical_files.txt
echo -e "$different_files" > different_files.txt
# - name: Commit and push diff
# run: |
# cd source
# git config user.name github-actions
# git config user.email [email protected]
# git add diff.txt
# git commit -m "Add diff"
# git push