From 6e587f01769e83f6dd8a4faead0d3d7306bd0c46 Mon Sep 17 00:00:00 2001 From: sjdonado Date: Sun, 2 Nov 2025 08:53:29 +0100 Subject: [PATCH] ci: update parsers workflow --- .github/workflows/update-parsers.yml | 63 ++++++++++++++++++++++++++++ app/services/cli.cr | 2 +- shard.yml | 2 +- 3 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/update-parsers.yml diff --git a/.github/workflows/update-parsers.yml b/.github/workflows/update-parsers.yml new file mode 100644 index 0000000..528dd40 --- /dev/null +++ b/.github/workflows/update-parsers.yml @@ -0,0 +1,63 @@ +name: Update Parsers + +on: + schedule: + # Run every two weeks on Sunday at 00:00 UTC (1st and 3rd Sunday of each month) + - cron: '0 0 1-7,15-21 * 0' + workflow_dispatch: # Allow manual trigger + +jobs: + update-parsers: + runs-on: ubuntu-latest + permissions: + contents: write + pull-requests: write + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Install Crystal + uses: crystal-lang/install-crystal@v1 + + - name: Install dependencies + run: shards install + + - name: Build CLI + run: crystal build scripts/cli.cr -o cli + + - name: Update parsers + run: ./cli --update-parsers + + - name: Check for changes + id: changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "has_changes=true" >> $GITHUB_OUTPUT + else + echo "has_changes=false" >> $GITHUB_OUTPUT + fi + + - name: Create Pull Request + if: steps.changes.outputs.has_changes == 'true' + uses: peter-evans/create-pull-request@v6 + with: + token: ${{ secrets.GITHUB_TOKEN }} + commit-message: 'chore: update parsers' + title: 'chore: Update UA regexes and GeoLite2 database' + body: | + ## Automated Parser Update + + This PR updates the following data files: + - User Agent parsing regexes + - GeoLite2 database + + **Triggered by**: Scheduled workflow (runs every 2 weeks) + **Date**: ${{ github.event.repository.updated_at }} + + Please review the changes and merge if everything looks good. + branch: automated/update-parsers + delete-branch: true + labels: | + dependencies + automated diff --git a/app/services/cli.cr b/app/services/cli.cr index 4105ad6..edb097c 100644 --- a/app/services/cli.cr +++ b/app/services/cli.cr @@ -73,7 +73,7 @@ module App::Services::Cli end end - def self.download_geolite_db + def self.update_geolite_db puts "Downloading GeoLite2 Country database..." FileUtils.mkdir_p("data") diff --git a/shard.yml b/shard.yml index e6f26be..f311cc4 100644 --- a/shard.yml +++ b/shard.yml @@ -2,7 +2,7 @@ name: bit version: 1.6.0 authors: - - Juan Rodriguez Ronado <@sjdonado> + - Juan Rodriguez Donado <@sjdonado> targets: bit: