Update main.yml
This commit is contained in:
parent
e1010d869e
commit
17a2054b42
|
@ -1,4 +1,4 @@
|
|||
name: Docker Pull and Package
|
||||
name: ARM64 Pull and Save Docker Image
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
@ -6,57 +6,34 @@ on:
|
|||
docker_images:
|
||||
description: 'Comma-separated list of Docker images to pull'
|
||||
required: true
|
||||
default: 'wukongdaily/box:latest'
|
||||
platform:
|
||||
description: 'Platform architecture (e.g., amd64, arm64)'
|
||||
required: true
|
||||
default: 'amd64'
|
||||
default: 'alpine:latest,ubuntu:latest' # 设置默认的 Docker 镜像列表
|
||||
|
||||
jobs:
|
||||
pull_and_package:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Clean up environment
|
||||
run: |
|
||||
# Clean up Docker images
|
||||
docker image prune -af
|
||||
|
||||
# Clean up temporary tar files
|
||||
rm -f *.tar
|
||||
|
||||
# Clean up other temporary files if necessary
|
||||
# rm -rf <other directories or files>
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v1
|
||||
|
||||
- name: Pull, Save, and Compress Docker Images
|
||||
- name: Pull Docker Images and Package
|
||||
run: |
|
||||
images="${{ github.event.inputs.docker_images }}"
|
||||
platform="${{ github.event.inputs.platform }}"
|
||||
IFS=',' read -r -a image_array <<< "$images"
|
||||
for image in "${image_array[@]}"; do
|
||||
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"
|
||||
|
||||
# Save image path to environment file
|
||||
echo "${image}_IMAGE_PATH=${{ runner.temp }}/${image_name}.tar.gz" >> $GITHUB_ENV
|
||||
docker pull "${image}" --platform "linux/arm64"
|
||||
docker save "${image}" -o "${image//\//_}-amd64.tar"
|
||||
done
|
||||
|
||||
- name: Clean up intermediate files
|
||||
run: |
|
||||
rm -f *.tar
|
||||
- name: Compress the TAR files
|
||||
run: tar -czf images.tar.gz *-amd64.tar
|
||||
|
||||
- name: Upload artifacts
|
||||
- name: Upload artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: docker-images-tar
|
||||
path: '*.tar.gz'
|
||||
path: images.tar.gz
|
||||
|
||||
- name: Clean up intermediate files
|
||||
run: |
|
||||
rm *-amd64.tar
|
||||
|
|
Loading…
Reference in New Issue