Data: Generate base-files package index #115
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: "Data: Generate base-files package index" | |
| on: | |
| schedule: | |
| - cron: '45 3 * * *' | |
| workflow_dispatch: | |
| repository_dispatch: | |
| types: ["Data: Update base-files info"] | |
| concurrency: | |
| group: ${{ github.workflow }} | |
| cancel-in-progress: false | |
| jobs: | |
| run-script: | |
| name: "Update base-files info" | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 30 | |
| if: ${{ github.repository_owner == 'Armbian' }} | |
| permissions: | |
| contents: write | |
| steps: | |
| # Step 1: Checkout the repository | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| # Step 2: Set up Python environment | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.x | |
| # Step 3: Install dependencies (if you have any) | |
| - name: Install dependencies | |
| run: | | |
| sudo apt install -y python3-requests python3-lxml | |
| # Step 4: Run the Python script | |
| - name: Run parser script | |
| run: | | |
| ./scripts/generate-base-files-info-json.py base-files | |
| # Step 5: Commit changes if any | |
| - name: Commit changes if any | |
| run: | | |
| set -euo pipefail | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git fetch origin data | |
| git checkout data | |
| mkdir -p data | |
| mv base-files.json data/base-files.json | |
| git add data/base-files.json | |
| if ! git diff --cached --quiet; then | |
| git commit -m "Update base-files package info" | |
| # Push with retry logic | |
| max_attempts=3 | |
| attempt=1 | |
| while [ $attempt -le $max_attempts ]; do | |
| if git push origin data; then | |
| echo "Successfully pushed to data branch" | |
| exit 0 | |
| fi | |
| # Pull with rebase to resolve conflicts | |
| echo "Push failed, attempting to pull and rebase..." >&2 | |
| if ! git pull --rebase origin data; then | |
| echo "Pull/rebase failed, will retry push..." >&2 | |
| fi | |
| attempt=$((attempt + 1)) | |
| done | |
| echo "Failed to push after $max_attempts attempts" >&2 | |
| exit 1 | |
| fi | |
| - name: "Generate directory" | |
| uses: peter-evans/repository-dispatch@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| event-type: "Web: Directory listing" | |