-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
workflows: add ip prefix duplicate check
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Change to the locations directory | ||
cd locations || exit 1 | ||
|
||
# Check for IPv4 duplicates | ||
ipv4_duplicates=$(sed -nE 's/^\s*prefix:\s*["'\''"]?([^"'\''\s#]+)["'\''"]?/\1/p' ./*.yml | sort | uniq -cd) | ||
|
||
# Check for IPv6 duplicates | ||
ipv6_duplicates=$(sed -nE 's/^\s*ipv6_prefix:\s*["'\''"]?([0-9a-fA-F:]+\/[0-9]+)["'\''"]?/\1/p' ./*.yml | sort | uniq -cd) | ||
|
||
|
||
if [ -n "$ipv4_duplicates" ] || [ -n "$ipv6_duplicates" ]; then | ||
if [ -n "$ipv4_duplicates" ]; then | ||
echo "Duplicate IPv4 prefixes found:" | ||
echo "$ipv4_duplicates" | ||
fi | ||
if [ -n "$ipv6_duplicates" ]; then | ||
echo "Duplicate IPv6 prefixes found:" | ||
echo "$ipv6_duplicates" | ||
fi | ||
exit 1 | ||
else | ||
echo "No duplicate prefixes found." | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
--- | ||
name: Check for duplicate IP prefixes | ||
|
||
on: [push, pull_request] # yamllint disable-line rule:truthy | ||
|
||
jobs: | ||
check-ip-prefix-duplicates: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Run IP prefix duplicate check | ||
run: | | ||
./.github/checks/check-ip-prefix-duplicates.sh |