name: ARM32 Pull and Save Docker Image

on:
  workflow_dispatch:
    inputs:
      docker_images:
        description: 'Comma-separated list of Docker images to pull'
        required: true
        default: 'alpine:latest,ubuntu:latest'  # 设置默认的 Docker 镜像列表

jobs:
  pull_and_package:
    runs-on: ubuntu-latest

    steps:
    - name: Checkout repository
      uses: actions/checkout@v2

    - name: Pull Docker Images and Package
      run: |
        images="${{ github.event.inputs.docker_images }}"
        IFS=',' read -r -a image_array <<< "$images"
        for image in "${image_array[@]}"; do
          docker pull "${image}" --platform "linux/arm/v7"
          docker save "${image}" -o "${image//\//_}-arm32.tar"
        done

    - name: Compress the TAR files
      run: tar -czf images.tar.gz *-amd64.tar

    - name: Upload artifact
      uses: actions/upload-artifact@v2
      with:
        name: docker-images-tar
        path: images.tar.gz

    - name: Clean up intermediate files
      run: |
        rm *-amd64.tar