Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 33
Gh v2 580b czarte and Dan#630
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
bb19b4add6873be2b77c43d13940e5d6dfa5e77a804ae5489a3cdcf06614f580c995bb3dd52e1c0780a3325bd401db154c63d26da3f7404fcd7e2ae1a8d6b2c89dca29c32dd1174259bcf1be29b714d97e9c7a64cfb1ba0eb83b4803546edd7a6ddbde6edaee7b7e3cd1dc3e9199cd044d50c3a41456e5b67a4b307d9121894deaf62fedaf2b57dc0ac82b4700bf223244c6df242dad5bc804242fef65a38fb89586c259f645fb807d46624d7202cc54cd278369e5410349cb7c955825e2d09c223db9a93127a44eb49ebd166e706e493777d5c82764c5d5240d4f36f37dca71c7070040bedea40ad2d14aeae56c67929a0ba6daab697b3e568c2ddb7659db8823f8185ef9b225535b1e7dd63071f34ba365be2e7File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| #!/bin/bash | ||
| # File to check (relative to repo root) | ||
| FILENAME="ip_country/src/dbip_country.rs" | ||
| if ! git diff --cached --name-only | grep -q "^$FILENAME$"; then | ||
| exit 0 | ||
| fi | ||
| # find 'Nonexistents' country in dbip_country.rs | ||
| @cat "$FILENAME" | grep '("NOEX", "Nonexistent")' | ||
| NONEXISTENT=$? | ||
| # Get local file size (staged version, not working copy) | ||
| LOCAL_SIZE=$(git ls-files --stage | grep "$FILENAME" | awk '{print $2}' | xargs git cat-file -s) | ||
| if [[ $LOCAL_SIZE -gt 1000000 || NONEXISTENT -gt 0 ]]; then | ||
| if [[ $LOCAL_SIZE -gt 1000000 ]]; then | ||
| echo "❌ Commit blocked: $FILENAME size it not dev version, we want to keep dev version under 1 MB." | ||
| echo " Local file size: $LOCAL_SIZE bytes" | ||
| fi | ||
| if [[ $NONEXISTENT -gt 0 ]]; then | ||
| echo "❌ Commit blocked: Dev file must contain '(\"NOEX\", \"Nonexistents\")' country" | ||
| fi | ||
| echo "" | ||
| echo " ⚡ Please sync the file with the remote before committing using:" | ||
| echo " git checkout HEAD -- ip_country/src/dbip_country.rs" | ||
| exit 1 | ||
| fi | ||
| # All good | ||
| exit 0 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| name: Download DBIP data and generate dbip_country.rs | ||
| on: | ||
| schedule: | ||
| - cron: "0 0 3 * *" # Runs at midnight on the 3rd of every month | ||
| env: | ||
| TEMP_DIR: '/tmp' | ||
| YEAR_MONTH: '01-9999' | ||
| permissions: | ||
| contents: write | ||
| jobs: | ||
| generate: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Set up Rust | ||
| uses: actions-rs/toolchain@v1 | ||
| with: | ||
| toolchain: stable | ||
| - name: Download DBIP data in MMDB format | ||
| run: | | ||
| export YEAR_MONTH=$(date +%Y-%m) | ||
| echo "TEMP_DIR=$(mktemp -d)" >> $GITHUB_ENV | ||
| echo "YEAR_MONTH=$YEAR_MONTH" >> $GITHUB_ENV | ||
| cd ip_country | ||
| mkdir -p dbip-data | ||
| curl -L -o dbip-data/dbip-country-lite.mmdb.gz "https://download.db-ip.com/free/dbip-country-lite-$YEAR_MONTH.mmdb.gz" | ||
| gunzip dbip-data/dbip-country-lite.mmdb.gz | ||
| - name: Generate Rust source file | ||
| run: | | ||
| cd ip_country | ||
| cargo run < "dbip-data/dbip-country-lite.mmdb" > "$TEMP_DIR"/dbip_country.rs | ||
| ls "$TEMP_DIR" | ||
| - name: Commit and push generated file | ||
| run: | | ||
| git config user.name "github-actions[bot]" | ||
| git config user.email "github-actions[bot]@users.noreply.github.com" | ||
| git fetch | ||
| BRANCH="$(git ls-remote --exit-code --heads origin generated-source 2>/dev/null || true)" | ||
| if [[ "$BRANCH" == "" ]] | ||
| then | ||
| git checkout -B generated-source | ||
| git rm -rf . | ||
| mkdir -p ip_country/src | ||
| else | ||
| git checkout generated-source | ||
| fi | ||
| DIFF="$(diff "${TEMP_DIR}"/dbip_country.rs ip_country/src/dbip_country.rs || true)" | ||
| if [[ "$DIFF" != "" || "$BRANCH" == "" ]] | ||
| then | ||
| mv "${TEMP_DIR}"/dbip_country.rs ip_country/src/dbip_country.rs | ||
| git add ip_country/src/dbip_country.rs | ||
| git commit -m "Update generated dbip_country ${YEAR_MONTH} Rust source file" || true | ||
| git push -u origin HEAD | ||
| fi |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.