Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
54 lines (50 loc) · 1.65 KB
/
Copy pathaction.yml
File metadata and controls
54 lines (50 loc) · 1.65 KB
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
name: Docker Push
description: Push the images docker-build saved to an archive with several tags to Docker Hub, only the given images.
inputs:
images:
description: The images as given to docker-build, one per line, the first word of each line is the image
required: true
tags:
description: Tags to push every image with, separated by whitespace
required: true
archive:
description: Path of the archive of docker-build
required: true
username:
description: Docker Hub username
required: true
password:
description: Docker Hub token
required: true
runs:
using: composite
steps:
- name: Load the images
shell: bash
env:
ARCHIVE: ${{ inputs.archive }}
run: docker load --quiet --input "$ARCHIVE"
- name: Login to Docker Hub
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
username: ${{ inputs.username }}
password: ${{ inputs.password }}
# the archive comes from a job that ran the build, so only the given images are pushed, with the given tags
- name: Push the images
shell: bash
env:
IMAGES: ${{ inputs.images }}
TAGS: ${{ inputs.tags }}
run: |
set -euo pipefail
while read -r image _; do
[ -z "$image" ] && continue
if ! docker image inspect "${image}:ci-build" > /dev/null 2>&1; then
echo "::error::the archive holds no image ${image}"
exit 1
fi
for tag in $TAGS; do
docker tag "${image}:ci-build" "${image}:${tag}"
docker push "${image}:${tag}"
done
done <<< "$IMAGES"