1
- name : Build and Deploy
1
+ name : Build Docker Image
2
2
3
3
on :
4
4
workflow_dispatch :
@@ -12,42 +12,41 @@ jobs:
12
12
runs-on : ubuntu-latest
13
13
steps :
14
14
- name : Checkout
15
- uses : actions/checkout@v3
15
+ uses : actions/checkout@v4
16
16
17
17
- name : Prepare Tags
18
18
id : prep
19
19
run : |
20
20
DOCKER_IMAGE=${{ secrets.DOCKER_USERNAME }}/${GITHUB_REPOSITORY#*/}
21
- VERSION=latest
22
21
23
- # If this is git tag, use the tag name as a docker tag
24
- if [[ $GITHUB_REF == refs/tags/* ]]; then
25
- VERSION=${GITHUB_REF#refs/tags/}
22
+ VERSION=${GITHUB_REF##*/}
23
+
24
+ # If this is the main branch, use 'latest' instead
25
+ if [[ $GITHUB_REF == refs/heads/main ]]; then
26
+ VERSION=latest
26
27
fi
28
+
27
29
TAGS="${DOCKER_IMAGE}:${VERSION}"
28
30
29
- # If the VERSION looks like a version number, assume that
30
- # this is the most recent version of the image and also
31
- # tag it 'latest'.
32
- if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
31
+ # If the version is a version number, also tag with 'latest'
32
+ if [[ $VERSION =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
33
33
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
34
34
fi
35
35
36
36
# Tag with the GitHub run id to create a unique tag for this run
37
37
TAGS="$TAGS,${DOCKER_IMAGE}:${GITHUB_RUN_ID}"
38
38
39
- # Set output parameters.
40
- echo ::set-output name=tags::${TAGS}
41
- echo ::set-output name=docker_image::${DOCKER_IMAGE}
39
+ echo "tags=${TAGS}" >> $GITHUB_OUTPUT
40
+ echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
42
41
43
42
- name : Set up QEMU
44
- uses : docker/setup-qemu-action@master
43
+ uses : docker/setup-qemu-action@v2
45
44
with :
46
45
platforms : all
47
46
48
47
- name : Set up Docker Buildx
49
48
id : buildx
50
- uses : docker/setup-buildx-action@master
49
+ uses : docker/setup-buildx-action@v2
51
50
52
51
- name : Login to Docker
53
52
if : github.event_name != 'pull_request'
0 commit comments