Skip to content

Commit

Permalink
infra: ensure template alignment across branches
Browse files Browse the repository at this point in the history
This commit implements a vital check to ensure consistent template alignment between the master
branch and other branches. It enforces that template files on the master branch remain the
definitive source of truth.
This decreases maintainance effort by having less files.
  • Loading branch information
KKoukiou committed Apr 18, 2024
1 parent 3a8bc12 commit 95b2ce4
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/template-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,38 @@ jobs:
exit 1
fi
done
infra-template-master-match-check:
runs-on: ubuntu-20.04
if: github.ref != 'refs/heads/master'
name: Templates match master branch

steps:
- name: Clone Anaconda repository
uses: actions/checkout@v3
with:
# TODO: Are we able to remove ref, fetch-depth and Rebase task? Seems that the checkout
# without ref is doing the rebase for us.
# otherwise we are testing target branch instead of the PR branch (see pull_request_target trigger)
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0

- name: Rebase to current
run: |
git config user.name github-actions
git config user.email [email protected]
git log --oneline -1 origin/${{ github.event.pull_request.base.ref }}
git rebase origin/${{ github.event.pull_request.base.ref }}
- name: Check if all changed template files are matching master branch
run: |
changed_files=$(git diff --diff-filter=M --name-only origin/master *.yml.j2)
if [ -n "$changed_files" ]; then
# print for debugging
echo "----- Changed template files -----"
echo "$changed_files"
echo "-------------------------"
exit 1
fi

0 comments on commit 95b2ce4

Please sign in to comment.