@@ -3,10 +3,6 @@ name: 'Build Container Action'
3
3
description : ' Builds and caches the image'
4
4
5
5
inputs :
6
- tag_name :
7
- description : ' user specified tag name'
8
- required : false
9
- default : ' '
10
6
osg_series :
11
7
description : >-
12
8
OSG release series used to install packages, intended for use
@@ -33,8 +29,11 @@ inputs:
33
29
description : ' Path to container files, including Dockerfile'
34
30
required : false
35
31
default : ' .'
36
- image_name :
37
- description : ' Name of the image to build, e.g. "opensciencegrid/software-base"'
32
+ output_image :
33
+ description : >-
34
+ Name of the image and tag for the resultant image build
35
+ following the <name>/<tag> format,
36
+ e.g. "opensciencegrid/osgvo-docker-pilot:3.6-release"
38
37
required : false
39
38
default : ' '
40
39
@@ -44,39 +43,49 @@ outputs:
44
43
Image name, including timestamp tag. Intended for use as a unique,
45
44
immutable identifier. For example,
46
45
"opensciencegrid/osgvo-docker-pilot:3.6-release-20221207-1729"
47
- value : ${{ steps.create_timestamp_tag.outputs.tags }}
46
+ value : ${{ steps.generate-tags.outputs.ts_image }}
47
+ cache_key :
48
+ description : >-
49
+ Key referencing the GitHub cache containing the layers of the
50
+ built container image
51
+ value : ${{ steps.generate-tags.outputs.cache_key }}
48
52
49
53
runs :
50
54
using : " composite"
51
55
steps :
52
56
- uses : actions/checkout@v2
53
57
54
- - id : generate-image-name
58
+ - id : generate-tags
59
+ name : Generate tag list
55
60
shell : bash
61
+ env :
62
+ OSG_REPO : ${{ inputs.osg_repo }}
63
+ OSG_SERIES : ${{ inputs.osg_series }}
64
+ OUTPUT_IMAGE : ${{ inputs.output_image }}
56
65
run : |
57
- if [[ -n "${{ inputs.image_name }}" ]]; then
58
- IMAGE_NAME="${{ inputs.image_name }}"
66
+ TIMESTAMP=$(date +%Y%m%d-%H%M)
67
+ DEFAULT_TAG=${OSG_SERIES}-${OSG_REPO}
68
+
69
+ if [[ -n "${OUTPUT_IMAGE}" ]]; then
70
+ IMAGE_NAME=${OUTPUT_IMAGE%:*}
59
71
elif [[ ${{ inputs.context }} == "." ]] || \
60
72
[[ ${{ inputs.context }} == "./" ]]; then
61
73
# Try to guess the image name from our docker repo naming conventions
62
74
# E.g., opensciencegrid/docker-frontier-squid
63
- IMAGE_NAME=${GITHUB_REPOSITORY/opensciencegrid\/docker-//}
75
+ IMAGE_NAME=${GITHUB_REPOSITORY/opensciencegrid\/docker-//}-${DEFAULT_TAG}
64
76
elif [[ -d ${{ inputs.context }} ]]; then
65
77
# Assume that the containing dir is the image name
66
- IMAGE_NAME=$(basename ${{ inputs.context }})
78
+ IMAGE_NAME=$(basename ${{ inputs.context }})-${DEFAULT_TAG}
67
79
else
68
- echo "No image_name provided and ${{ inputs.context }} is not a directory"
80
+ echo "No output_image provided and ${{ inputs.context }} is not a directory"
69
81
exit 1
70
82
fi
71
- echo "::set-output name=image::${IMAGE_NAME,,}"
72
83
73
- - id : create_timestamp_tag
74
- shell : bash
75
- run : echo "::set-output name=tags::${IMAGE}:${TAGNAME:-$DEFAULTTAG}-$(date +%Y%m%d-%H%M)"
76
- env :
77
- IMAGE : ${{ steps.generate-image-name.outputs.image }}
78
- TAGNAME : ${{ inputs.tag_name }}
79
- DEFAULTTAG : ${{ inputs.osg_series }}-${{ inputs.repo }}
84
+ TIMESTAMP_IMAGE=${IMAGE_NAME}-${TIMESTAMP}
85
+
86
+ echo "tag_list=${IMAGE_NAME},${TIMESTAMP_IMAGE}" >> ${GITHUB_OUTPUT}
87
+ echo "ts_image=${TIMESTAMP-IMAGE}" >> ${GITHUB_OUTPUT}
88
+ echo "cache_key=$(tr ':/' '_' <<< $TIMESTAMP_IMAGE)_buildx_${GITHUB_SHA}" >> ${GITHUB_OUTPUT}
80
89
81
90
- name : Set up Docker Buildx
82
91
uses : docker/setup-buildx-action@v1
@@ -90,12 +99,12 @@ runs:
90
99
BASE_YUM_REPO=${{ inputs.osg_repo }}
91
100
BASE_OS=${{ inputs.base_os }}
92
101
BASE_OSG_SERIES=${{ inputs.osg_series }}
93
- TIMESTAMP_TAG=${{ steps.create_timestamp_tag .outputs.tags }}
94
- tags : " latest "
102
+ TIMESTAMP_TAG=${{ steps.generate-tags .outputs.ts_image }}
103
+ tags : ${{ steps.generate-tags.outputs.tag_list }}
95
104
cache-to : type=local,dest=/tmp/.buildx-cache,mode=max
96
105
97
106
- name : Cache Docker images
98
107
uses : actions/cache@v2
99
108
with :
100
109
path : /tmp/.buildx-cache
101
- key : ${{ steps.generate-image-name .outputs.image }}_${{ inputs.osg_series}}_${{ inputs.osg_repo }}_buildx_${{ github.sha }}_${{ github.run_id }}
110
+ key : ${{ steps.generate-tags .outputs.cache_key }}
0 commit comments