Generate User Agents #90
This file contains hidden or 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
| name: Generate User Agents | |
| on: | |
| schedule: | |
| - cron: '*/5 * * * *' | |
| workflow_dispatch: | |
| push: | |
| branches: [ main ] | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: ua-generator | |
| cancel-in-progress: false | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r requirements.txt | |
| - name: Generate | |
| run: python scripts/generate.py | |
| - name: Get snapshot filename | |
| id: snapshot | |
| run: | | |
| LATEST=$(ls -t releases/*.md 2>/dev/null | head -1) | |
| if [ -z "$LATEST" ]; then | |
| echo "No snapshot file found" | |
| exit 1 | |
| fi | |
| NAME=$(basename "$LATEST" .md) | |
| echo "name=$NAME" >> $GITHUB_OUTPUT | |
| echo "Snapshot name: $NAME" | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: snapshot-${{ github.run_id }} | |
| name: Snapshot ${{ steps.snapshot.outputs.name }} | |
| body_path: releases/${{ steps.snapshot.outputs.name }}.md | |
| files: | | |
| releases/${{ steps.snapshot.outputs.name }}.zip | |
| releases/${{ steps.snapshot.outputs.name }}.rar | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| continue-on-error: true | |
| - name: Commit and push | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action Bot" | |
| git add -A | |
| if git diff --staged --quiet; then | |
| echo "No changes" | |
| exit 0 | |
| fi | |
| TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M UTC") | |
| git commit -m "UA snapshot $TIMESTAMP" | |
| git push origin main |