Skip to content

Commit ed935d1

Browse files
authored
Disable change on minigraph and init_cfg.json (#19597)
Why I did it The further change of minigraph.py and init_cfg.json should be blocked to align with PROD env. How I did it Add checker to block change How to verify it PR test
1 parent c57f727 commit ed935d1

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

.github/workflows/protect-file.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Protect certain files to avoid further changes
2+
3+
on:
4+
push:
5+
branches:
6+
- 'master'
7+
- '202[2-9][0-9][0-9]'
8+
pull_request:
9+
branches:
10+
- 'master'
11+
- '202[2-9][0-9][0-9]'
12+
13+
jobs:
14+
check-file:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v3
19+
20+
- name: Fetch base branch
21+
run: |
22+
git fetch origin ${GITHUB_BASE_REF}
23+
24+
- name: Check protected files
25+
run: |
26+
echo "Starting file check step"
27+
protected_files=('src/sonic-config-engine/minigraph.py' 'files/build_templates/init_cfg.json.j2')
28+
base_branch=$(git rev-parse origin/${GITHUB_BASE_REF})
29+
30+
for protected_file in "${protected_files[@]}"; do
31+
echo "Checking ${protected_file}"
32+
if git diff --name-only $base_branch | grep -q "^${protected_file}\$"; then
33+
echo "Error: You are trying to modify ${protected_file}, which is protected."
34+
exit 1
35+
fi
36+
done
37+
echo "No changes detected in protected files"

0 commit comments

Comments
 (0)