diff --git a/.github/workflows/add-icons-batch.yml b/.github/workflows/add-icons-batch.yml deleted file mode 100644 index d72995ad..00000000 --- a/.github/workflows/add-icons-batch.yml +++ /dev/null @@ -1,191 +0,0 @@ -name: Add Multiple Icons (Batch) - -on: - workflow_dispatch: - inputs: - submissionIds: - description: "Comma-separated list of PocketBase submission IDs to import" - required: true - type: string - dryRun: - description: "When true, skip writes/commit/PocketBase status update" - required: false - default: false - type: boolean - -jobs: - # First job: Parse the comma-separated input into a JSON array - setup: - runs-on: ubuntu-latest - outputs: - matrix: ${{ steps.set-matrix.outputs.matrix }} - count: ${{ steps.set-matrix.outputs.count }} - steps: - - name: Parse submission IDs into matrix - id: set-matrix - run: | - # Convert comma-separated input to JSON array - # Trim whitespace from each ID - IDS='${{ inputs.submissionIds }}' - JSON_ARRAY=$(echo "$IDS" | jq -Rc 'split(",") | map(gsub("^\\s+|\\s+$"; "")) | map(select(length > 0))') - COUNT=$(echo "$JSON_ARRAY" | jq 'length') - echo "matrix=$JSON_ARRAY" >> "$GITHUB_OUTPUT" - echo "count=$COUNT" >> "$GITHUB_OUTPUT" - echo "Parsed $COUNT submission IDs: $JSON_ARRAY" - - # Second job: Process each icon sequentially using matrix strategy - process-icons: - needs: setup - runs-on: ubuntu-latest - strategy: - max-parallel: 1 # Process one at a time for sequential execution chain - fail-fast: false # Continue processing other icons even if one fails - matrix: - submissionId: ${{ fromJSON(needs.setup.outputs.matrix) }} - outputs: - processed: ${{ steps.import.outputs.submission_name }} - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Setup Bun - uses: oven-sh/setup-bun@v1 - - - name: Import icon from PocketBase submission - id: import - env: - PB_URL: ${{ secrets.PB_URL }} - PB_ADMIN_TOKEN: ${{ secrets.PB_ADMIN_TOKEN }} - run: | - echo "Processing submission: ${{ matrix.submissionId }}" - ARGS=(--submission-id "${{ matrix.submissionId }}") - if [ "${{ inputs.dryRun }}" = "true" ]; then - ARGS+=("--dry-run") - fi - ARGS+=("--gha-output" "$GITHUB_OUTPUT") - bun run scripts/import-icon.ts "${ARGS[@]}" - - - name: Check for changes - id: git-diff - run: | - if git diff --quiet; then - echo "has_changes=false" >> "$GITHUB_OUTPUT" - else - echo "has_changes=true" >> "$GITHUB_OUTPUT" - fi - - - name: Upload changes as artifact - if: ${{ !inputs.dryRun && steps.git-diff.outputs.has_changes == 'true' }} - uses: actions/upload-artifact@v4 - with: - name: icon-changes-${{ matrix.submissionId }} - path: | - svg/ - png/ - webp/ - icons/ - DATA.json - tree.json - include-hidden-files: false - - - name: Save submission info - if: ${{ !inputs.dryRun && steps.git-diff.outputs.has_changes == 'true' }} - run: | - mkdir -p submission-info - echo '${{ matrix.submissionId }}' > submission-info/id.txt - echo '${{ steps.import.outputs.submission_name }}' > submission-info/name.txt - echo '${{ steps.import.outputs.approver }}' > submission-info/approver.txt - - - name: Upload submission info - if: ${{ !inputs.dryRun && steps.git-diff.outputs.has_changes == 'true' }} - uses: actions/upload-artifact@v4 - with: - name: submission-info-${{ matrix.submissionId }} - path: submission-info/ - - # Final job: Combine all changes and push once - commit-and-push: - needs: [setup, process-icons] - runs-on: ubuntu-latest - if: ${{ !inputs.dryRun }} - permissions: - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - - name: Download all icon changes - uses: actions/download-artifact@v5 - with: - pattern: icon-changes-* - merge-multiple: true - - - name: Download all submission info - uses: actions/download-artifact@v5 - with: - pattern: submission-info-* - path: all-submissions - - - name: Check for changes - id: git-diff - run: | - if git diff --quiet; then - echo "has_changes=false" >> "$GITHUB_OUTPUT" - else - echo "has_changes=true" >> "$GITHUB_OUTPUT" - fi - - - name: Configure git user - if: steps.git-diff.outputs.has_changes == 'true' - run: | - git config user.name "github-actions[bot]" - git config user.email "41898282+github-actions[bot]@users.noreply.github.com" - - - name: Build commit message - if: steps.git-diff.outputs.has_changes == 'true' - id: commit-msg - run: | - # Collect all submission names for the commit message - NAMES="" - COUNT=0 - for dir in all-submissions/submission-info-*/; do - if [ -d "$dir" ]; then - NAME=$(cat "$dir/name.txt" 2>/dev/null || echo "unknown") - ID=$(cat "$dir/id.txt" 2>/dev/null || echo "unknown") - APPROVER=$(cat "$dir/approver.txt" 2>/dev/null || echo "unknown") - if [ -n "$NAMES" ]; then - NAMES="$NAMES, $NAME" - else - NAMES="$NAME" - fi - COUNT=$((COUNT + 1)) - fi - done - - if [ $COUNT -eq 1 ]; then - MSG="chore: add icon \"$NAMES\" (batch import)" - else - MSG="chore: add $COUNT icons ($NAMES) (batch import)" - fi - - echo "message=$MSG" >> "$GITHUB_OUTPUT" - echo "Commit message: $MSG" - - - name: Commit changes - if: steps.git-diff.outputs.has_changes == 'true' - run: | - git add . - git commit -m "${{ steps.commit-msg.outputs.message }}" - - - name: Pull before push - if: steps.git-diff.outputs.has_changes == 'true' - run: git pull --rebase origin main - - - name: Push changes - if: steps.git-diff.outputs.has_changes == 'true' - run: git push -