verified MrBZBZ/LeavesHack #412
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: scan | |
| concurrency: | |
| group: "main" | |
| cancel-in-progress: false | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "config.json" | |
| - ".github/workflows/scan.yml" | |
| - "**/*.go" | |
| schedule: | |
| - cron: "0 21 * * *" | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.22" | |
| - name: Install Go dependencies | |
| run: go mod tidy | |
| - name: Remove old output files | |
| run: rm -rf data && mkdir -p data | |
| - name: Fetch invalid-repo-log.txt from addons branch | |
| run: | | |
| set -euo pipefail | |
| git fetch origin addons || true | |
| if git show origin/addons:invalid-repo-log.txt > data/invalid-repo-log.txt 2>/dev/null; then | |
| echo "Loaded invalid-repo-log.txt from addons branch" | |
| else | |
| echo "No invalid-repo-log.txt found on addons branch; creating empty file" | |
| : > invalid-repo-log.txt | |
| fi | |
| - name: Run scanner and generate files | |
| run: go run ./cmd/main.go config.json data/addons.json data/invalid-repo-log.txt | |
| env: | |
| KEY: ${{ secrets.KEY }} | |
| - name: Deploy to addons branch | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Create addons branch if it doesn't exist | |
| git fetch origin addons || git checkout --orphan addons | |
| # If branch exists, checkout and clean it | |
| git checkout addons 2>/dev/null || git checkout --orphan addons | |
| git rm -rf . || true | |
| # Copy the generated files | |
| cp data/addons.json addons.json | |
| cp data/invalid-repo-log.txt invalid-repo-log.txt | |
| # Add and commit | |
| git add addons.json | |
| git add invalid-repo-log.txt | |
| git commit -m "updated addons" || echo "No changes to commit" | |
| # Push to addons branch | |
| git push origin addons --force |