2024-06-15 16:52:53 +08:00
|
|
|
name: Docker Pull and Package
|
|
|
|
|
|
|
|
on:
|
|
|
|
workflow_dispatch:
|
|
|
|
inputs:
|
|
|
|
docker_images:
|
|
|
|
description: 'Comma-separated list of Docker images to pull'
|
|
|
|
required: true
|
2024-06-15 17:19:42 +08:00
|
|
|
default: 'alpine:latest,ubuntu:latest'
|
2024-06-15 17:10:16 +08:00
|
|
|
platform:
|
|
|
|
description: 'Platform architecture (e.g., amd64, arm64)'
|
|
|
|
required: true
|
|
|
|
default: 'amd64'
|
2024-06-15 16:52:53 +08:00
|
|
|
|
|
|
|
jobs:
|
|
|
|
pull_and_package:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
|
2024-06-15 17:10:16 +08:00
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
|
|
|
|
|
|
|
- name: Pull, Save, and Compress Docker Images
|
2024-06-15 16:52:53 +08:00
|
|
|
run: |
|
|
|
|
images="${{ github.event.inputs.docker_images }}"
|
2024-06-15 17:10:16 +08:00
|
|
|
platform="${{ github.event.inputs.platform }}"
|
2024-06-15 16:52:53 +08:00
|
|
|
IFS=',' read -r -a image_array <<< "$images"
|
|
|
|
for image in "${image_array[@]}"; do
|
2024-06-15 17:10:16 +08:00
|
|
|
echo "Pulling $image for platform $platform"
|
|
|
|
docker pull --platform "$platform" "$image"
|
|
|
|
image_name="${image//\//_}_${platform}"
|
|
|
|
docker save "$image" -o "${image_name}.tar"
|
|
|
|
tar -czf "${image_name}.tar.gz" "${image_name}.tar"
|
|
|
|
rm -f "${image_name}.tar"
|
2024-06-15 17:19:42 +08:00
|
|
|
|
|
|
|
# Save image information to environment file
|
|
|
|
echo "${image}_IMAGE_PATH=${{ runner.temp }}/${image_name}.tar.gz" >> $GITHUB_ENV
|
2024-06-15 16:52:53 +08:00
|
|
|
done
|
|
|
|
|
2024-06-15 17:10:16 +08:00
|
|
|
- name: Clean up intermediate files
|
|
|
|
run: |
|
|
|
|
rm -f *.tar
|
2024-06-15 16:52:53 +08:00
|
|
|
|
2024-06-15 17:10:16 +08:00
|
|
|
- name: Upload artifacts
|
2024-06-15 16:52:53 +08:00
|
|
|
uses: actions/upload-artifact@v2
|
|
|
|
with:
|
|
|
|
name: docker-images-tar
|
2024-06-15 17:10:16 +08:00
|
|
|
path: '*.tar.gz'
|