🏡 index : quine-global-labs/mirror-get-aurora-dev-iso.git

name: Promote ISOs to Production
on:
  workflow_dispatch:
    inputs:
      dry_run:
        description: 'Run in dry-run mode (preview changes without copying)'
        required: false
        type: boolean
        default: true

jobs:
  promote:
    name: Promote ISOs from Test to Production
    runs-on: ubuntu-latest
    permissions:
      contents: read
    # defined here, these apply to ALL steps in this job
    env:
      # Test Bucket Config (Source)
      RCLONE_CONFIG_R2_TEST_TYPE: s3
      RCLONE_CONFIG_R2_TEST_PROVIDER: Cloudflare
      RCLONE_CONFIG_R2_TEST_ACCESS_KEY_ID: ${{ secrets.AURORA_DL_TEST_R2_ACCESS_KEY_ID }}
      RCLONE_CONFIG_R2_TEST_SECRET_ACCESS_KEY: ${{ secrets.AURORA_DL_TEST_R2_ACCESS_KEY_SECRET }}
      RCLONE_CONFIG_R2_TEST_REGION: auto
      RCLONE_CONFIG_R2_TEST_ENDPOINT: ${{ secrets.AURORA_DL_TEST_R2_ENDPOINT }}

     # Production Bucket Config (Destination)
      RCLONE_CONFIG_R2_PROD_TYPE: s3
      RCLONE_CONFIG_R2_PROD_PROVIDER: Cloudflare
      RCLONE_CONFIG_R2_PROD_ACCESS_KEY_ID: ${{ secrets.AURORA_DL_R2_ACCESS_KEY_ID }}
      RCLONE_CONFIG_R2_PROD_SECRET_ACCESS_KEY: ${{ secrets.AURORA_DL_R2_ACCESS_SECRET_KEY }}
      RCLONE_CONFIG_R2_PROD_REGION: auto
      RCLONE_CONFIG_R2_PROD_ENDPOINT: ${{ secrets.AURORA_DL_R2_ENDPOINT }}

    steps:
      - name: Install rclone
        run: /home/linuxbrew/.linuxbrew/bin/brew install rclone

      - name: List files in Test bucket
        run: |
          echo "Files in Test bucket (including testing - testing ISOs will NOT be promoted):"
          /home/linuxbrew/.linuxbrew/bin/rclone ls R2_TEST:aurora-dl-test \
            --filter "+ *.iso" \
            --filter "+ *.iso-CHECKSUM" \
            --filter "- *"
          echo "::notice::Testing ISOs (*-testing-*) are listed above but will be excluded from promotion."

      - name: Promote ISOs (Dry Run)
        if: inputs.dry_run == true
        run: |
          echo "Running in DRY RUN mode - no files will be copied"
          /home/linuxbrew/.linuxbrew/bin/rclone sync R2_TEST:aurora-dl-test R2_PROD:aurora-dl \
            --filter "- *-testing-*" \
            --filter "- *-webui-*" \
            --filter "+ *.iso" \
            --filter "+ *.iso-CHECKSUM" \
            --filter "- *" \
            --dry-run \
            --verbose

      - name: Promote ISOs (Production)
        if: inputs.dry_run == false
        run: |
          echo "Promoting ISOs from Test to Production"
          /home/linuxbrew/.linuxbrew/bin/rclone sync R2_TEST:aurora-dl-test R2_PROD:aurora-dl \
            --filter "- *-testing-*" \
            --filter "- *-webui-*" \
            --filter "+ *.iso" \
            --filter "+ *.iso-CHECKSUM" \
            --filter "- *" \
            --verbose \
            --progress

      - name: Verify promotion
        if: inputs.dry_run == false
        run: |
          echo "Files in Production bucket after promotion:"
          /home/linuxbrew/.linuxbrew/bin/rclone ls R2_PROD:aurora-dl \
            --filter "+ *.iso" \
            --filter "+ *.iso-CHECKSUM" \
            --filter "- *"