-
Notifications
You must be signed in to change notification settings - Fork 0
55 lines (48 loc) · 1.51 KB
/
image_artifact.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
name: Artifact Container Images
on:
workflow_call:
inputs:
image_names:
description: "A space separated list of full image names to upload, including tag."
required: true
type: string
outputs:
artifact_name:
description: "The artifact name (default: `artifact`)."
value: "images"
jobs:
package-and-upload:
runs-on: ubuntu-latest
steps:
- name: Package Images
run: |
# Make artifact dir
mkdir -p /tmp/images
echo "Provided images:"
echo "${{ inputs.image_names }}"
echo ""
images_array=(${{ inputs.image_names }})
echo "Parsed array: ${images_array}"
echo "Images to artifact:"
for image in "${images_array[@]}"; do
echo "$image"
done
echo ""
# Iterate images
for image in "${images_array[@]}"; do
echo "Processing image ${image}"
docker pull "${image}"
if [ $? -eq 0 ]; then
img_underscores=${image//[:\/.]/_}
echo "Packaging image to /tmp/images/${img_underscores}.tar"
docker image save "${image}" \
--output /tmp/images/${img_underscores}.tar
else
echo "Failed to pull the image: ${image}"
fi
done
- name: Upload Artifact Dir
uses: actions/upload-artifact@v4
with:
path: /tmp/images
name: images