Skip to content

Commit

Permalink
workflows: add ip prefix duplicate check
Browse files Browse the repository at this point in the history
  • Loading branch information
Noki committed Jul 22, 2024
1 parent 5430010 commit d1bbfbc
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/checks/check-ip-prefix-duplicates.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Change to the locations directory
cd locations || exit 1

# Extract IPv4 prefixes, sort them, and check for duplicates
ipv4_duplicates=$(cat * | sed -nE 's/^\s*prefix:\s*["'\'']?([^"\''\s#]+)["'\'']?\s*(#.*)?$/\1/p' | sort | uniq -cd)

# Extract IPv6 prefixes, sort them, and check for duplicates
ipv6_duplicates=$(cat * | sed -n 's/.*ipv6_prefix:\s*["'\'']\?\([0-9a-fA-F:]\+::\/[0-9]\+\)["'\'']\?.*/\1/p' | 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
16 changes: 16 additions & 0 deletions .github/workflows/check-ip-prefix-duplicates.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Check for duplicate IP prefixes

on: [push, pull_request]

jobs:
ipv6-check:
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

0 comments on commit d1bbfbc

Please sign in to comment.