@@ -147,43 +147,40 @@ jobs:
147147 - name : Prepare
148148 id : prepare
149149 env :
150- NV : ${{ inputs.release_tag }}
150+ BRANCH : ${{ github.ref }}
151+ COMMIT : ${{ inputs.release_commit }}
152+ NEW_TAG : ${{ inputs.release_tag }}
151153 run : |
152- # get branch name
153- BRANCH=${GITHUB_HEAD_REF}
154+ # get variables
155+ branch="${BRANCH}"
156+ commit="${COMMIT}"
157+ clone_url="${{ github.event.repository.clone_url }}"
154158
155- RELEASE="${{ inputs.publish_release }}"
156- COMMIT="${{ inputs.release_commit }}"
157-
158- if [ -z "${BRANCH}" ]; then
159+ if [ "${{ github.event_name }}" == "push" ]; then
159160 echo "This is a PUSH event"
160- BRANCH="${{ github.ref_name }}"
161- CLONE_URL="${{ github.event.repository.clone_url }}"
162- else
163- echo "This is a PULL REQUEST event"
164- CLONE_URL="${{ github.event.pull_request.head.repo.clone_url }}"
161+ branch="${{ github.ref_name }}"
165162 fi
166163
167164 # setup the tags
168165 BASE_TAG="${{ needs.check_dockerfiles.outputs.base_tag }}"
169166
170- TAGS="${BASE_TAG}:${COMMIT :0:7}${{ matrix.tag }},ghcr.io/${BASE_TAG}:${COMMIT :0:7}${{ matrix.tag }}"
167+ TAGS="${BASE_TAG}:${commit :0:7}${{ matrix.tag }},ghcr.io/${BASE_TAG}:${commit :0:7}${{ matrix.tag }}"
171168
172- if [[ "${GITHUB_REF }" == refs/heads/master ]]; then
169+ if [[ "${branch }" == refs/heads/master ]]; then
173170 TAGS="${TAGS},${BASE_TAG}:latest${{ matrix.tag }},ghcr.io/${BASE_TAG}:latest${{ matrix.tag }}"
174171 TAGS="${TAGS},${BASE_TAG}:master${{ matrix.tag }},ghcr.io/${BASE_TAG}:master${{ matrix.tag }}"
175172 else
176173 TAGS="${TAGS},${BASE_TAG}:test${{ matrix.tag }},ghcr.io/${BASE_TAG}:test${{ matrix.tag }}"
177174 fi
178175
179- if [[ "${NV }" != "" ]]; then
180- TAGS="${TAGS},${BASE_TAG}:${NV }${{ matrix.tag }},ghcr.io/${BASE_TAG}:${NV }${{ matrix.tag }}"
176+ if [[ "${NEW_TAG }" != "" ]]; then
177+ TAGS="${TAGS},${BASE_TAG}:${NEW_TAG }${{ matrix.tag }},ghcr.io/${BASE_TAG}:${NEW_TAG }${{ matrix.tag }}"
181178 fi
182179
183180 # parse custom directives out of dockerfile
184181 # try to get the platforms from the dockerfile custom directive, i.e. `# platforms: xxx,yyy`
185182 # directives for PR event, i.e. not push event
186- if [[ "${RELEASE} " == "false" ] ]; then
183+ if [ "${{ github.event_name }} " == "pull_request" ]; then
187184 while read -r line; do
188185 if [[ $line == "# platforms_pr: "* && $PLATFORMS == "" ]]; then
189186 # echo the line and use `sed` to remove the custom directive
@@ -221,9 +218,9 @@ jobs:
221218 fi
222219
223220 {
224- echo "branch=${BRANCH }";
221+ echo "branch=${branch }";
225222 echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')";
226- echo "clone_url=${CLONE_URL }";
223+ echo "clone_url=${clone_url }";
227224 echo "artifacts=${ARTIFACTS}";
228225 echo "no_cache_filters=${NO_CACHE_FILTERS}";
229226 echo "platforms=${PLATFORMS}";
0 commit comments