1
- name : ' Build Container Action'
2
-
3
- description : ' Builds and caches the image'
1
+ name : ' OSG Build Container Action'
2
+ description : ' Builds and optionally caches/pushes the image'
4
3
5
4
inputs :
6
5
osg_series :
@@ -41,6 +40,27 @@ inputs:
41
40
Store built images in GitHub the GitHub cache (default: true)
42
41
required : false
43
42
default : true
43
+ push_image :
44
+ description : >-
45
+ Push the built image to a container registry (default: false).
46
+ Requires 'registry_url', 'registry_user', and 'registry_pass'
47
+ arguments.
48
+ required : false
49
+ default : false
50
+ registry_url :
51
+ description : >
52
+ URL for the target container registry
53
+ required : false
54
+ registry_user :
55
+ description : >-
56
+ Username for the target container registry. Should be kept in
57
+ some form of GitHub secret.
58
+ required : false
59
+ registry_pass :
60
+ description : >-
61
+ Password for the target container registry. Should be kept in
62
+ some form of GitHub secret.
63
+ required : false
44
64
45
65
outputs :
46
66
tags :
@@ -60,15 +80,22 @@ runs:
60
80
steps :
61
81
- uses : actions/checkout@v2
62
82
83
+ - name : Check input requirements
84
+ if : inputs.push_image && inputs.registry_url && inputs.registry_user && ! inputs.registry_pass
85
+ shell : bash
86
+ run : |
87
+ echo "::error ::'push_image' specified but missing 'registry_url', 'registry_user', or 'registry_pass'"
88
+ exit 1
89
+
63
90
- id : generate-tags
64
91
name : Generate tag list
65
92
shell : bash
66
93
env :
94
+ REGISTRY : ${{ inputs.registry_url }}
67
95
OSG_REPO : ${{ inputs.osg_repo }}
68
96
OSG_SERIES : ${{ inputs.osg_series }}
69
97
OUTPUT_IMAGE : ${{ inputs.output_image }}
70
98
run : |
71
- TIMESTAMP=$(date +%Y%m%d-%H%M)
72
99
DEFAULT_TAG=${OSG_SERIES}-${OSG_REPO}
73
100
74
101
if [[ -n "${OUTPUT_IMAGE}" ]]; then
@@ -86,6 +113,12 @@ runs:
86
113
exit 1
87
114
fi
88
115
116
+ # If we're pushing images, we need to prepend the registry for the build-push-action
117
+ if [[ -n "${REGISTRY}" ]]; then
118
+ IMAGE_NAME=${REGISTRY}/${IMAGE_NAME}
119
+ fi
120
+
121
+ TIMESTAMP=$(date +%Y%m%d-%H%M)
89
122
TIMESTAMP_IMAGE=${IMAGE_NAME}-${TIMESTAMP}
90
123
91
124
echo "tag_list=${IMAGE_NAME},${TIMESTAMP_IMAGE}" >> ${GITHUB_OUTPUT}
@@ -95,10 +128,18 @@ runs:
95
128
- name : Set up Docker Buildx
96
129
uses : docker/setup-buildx-action@v1
97
130
131
+ - name : Container Registry Login
132
+ if : inputs.push_image
133
+ uses : docker/login-action@v1
134
+ with :
135
+ registry : ${{ inputs.registry_url }}
136
+ username : ${{ inputs.registry_user }}
137
+ password : ${{ inputs.registry_pass }}
138
+
98
139
- name : Build and push Docker images
99
140
100
141
with :
101
- push : false
142
+ push : ${{ inputs.push_image }}
102
143
context : ${{ inputs.context }}
103
144
build-args : |
104
145
BASE_YUM_REPO=${{ inputs.osg_repo }}
0 commit comments