@@ -147,43 +147,41 @@ 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 }}
153+ shell : bash
151154 run : |
152- # get branch name
153- BRANCH=${GITHUB_HEAD_REF}
155+ # get variables
156+ branch="${BRANCH:-master}"
157+ commit="${COMMIT:-${{ github.sha }}}"
158+ clone_url="${{ github.event.repository.clone_url }}"
154159
155- RELEASE="${{ inputs.publish_release }}"
156- COMMIT="${{ inputs.release_commit }}"
157-
158- if [ -z "${BRANCH}" ]; then
160+ if [ "${{ github.event_name }}" == "push" ]; then
159161 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 }}"
162+ branch="${{ github.ref_name }}"
165163 fi
166164
167165 # setup the tags
168166 BASE_TAG="${{ needs.check_dockerfiles.outputs.base_tag }}"
169167
170- TAGS="${BASE_TAG}:${COMMIT :0:7}${{ matrix.tag }},ghcr.io/${BASE_TAG}:${COMMIT :0:7}${{ matrix.tag }}"
168+ TAGS="${BASE_TAG}:${commit :0:7}${{ matrix.tag }},ghcr.io/${BASE_TAG}:${commit :0:7}${{ matrix.tag }}"
171169
172- if [[ "${GITHUB_REF }" == refs/heads/master ]]; then
170+ if [[ "${branch }" == refs/heads/master ]]; then
173171 TAGS="${TAGS},${BASE_TAG}:latest${{ matrix.tag }},ghcr.io/${BASE_TAG}:latest${{ matrix.tag }}"
174172 TAGS="${TAGS},${BASE_TAG}:master${{ matrix.tag }},ghcr.io/${BASE_TAG}:master${{ matrix.tag }}"
175173 else
176174 TAGS="${TAGS},${BASE_TAG}:test${{ matrix.tag }},ghcr.io/${BASE_TAG}:test${{ matrix.tag }}"
177175 fi
178176
179- if [[ "${NV }" != "" ]]; then
180- TAGS="${TAGS},${BASE_TAG}:${NV }${{ matrix.tag }},ghcr.io/${BASE_TAG}:${NV }${{ matrix.tag }}"
177+ if [[ "${NEW_TAG }" != "" ]]; then
178+ TAGS="${TAGS},${BASE_TAG}:${NEW_TAG }${{ matrix.tag }},ghcr.io/${BASE_TAG}:${NEW_TAG }${{ matrix.tag }}"
181179 fi
182180
183181 # parse custom directives out of dockerfile
184182 # try to get the platforms from the dockerfile custom directive, i.e. `# platforms: xxx,yyy`
185183 # directives for PR event, i.e. not push event
186- if [[ "${RELEASE} " == "false" ] ]; then
184+ if [ "${{ github.event_name }} " == "pull_request" ]; then
187185 while read -r line; do
188186 if [[ $line == "# platforms_pr: "* && $PLATFORMS == "" ]]; then
189187 # echo the line and use `sed` to remove the custom directive
@@ -221,9 +219,9 @@ jobs:
221219 fi
222220
223221 {
224- echo "branch=${BRANCH }";
222+ echo "branch=${branch }";
225223 echo "build_date=$(date -u +'%Y-%m-%dT%H:%M:%SZ')";
226- echo "clone_url=${CLONE_URL }";
224+ echo "clone_url=${clone_url }";
227225 echo "artifacts=${ARTIFACTS}";
228226 echo "no_cache_filters=${NO_CACHE_FILTERS}";
229227 echo "platforms=${PLATFORMS}";
@@ -234,8 +232,8 @@ jobs:
234232 uses : docker/setup-qemu-action@v3
235233
236234 - name : Set up Docker Buildx
237- uses : docker/setup-buildx-action@v3
238235 id : buildx
236+ uses : docker/setup-buildx-action@v3
239237
240238 - name : Cache Docker Layers
241239 uses : actions/cache@v4
@@ -261,6 +259,7 @@ jobs:
261259 password : ${{ secrets.GH_BOT_TOKEN }}
262260
263261 - name : Add problem matcher
262+ shell : bash
264263 run : |
265264 if [ -f "${{ github.workspace }}/.github/matchers/docker.json" ]; then
266265 echo "::add-matcher::${{ github.workspace }}/.github/matchers/docker.json"
@@ -289,6 +288,7 @@ jobs:
289288
290289 - name : Arrange Artifacts
291290 if : steps.prepare.outputs.artifacts == 'true'
291+ shell : bash
292292 run : |
293293 # create artifacts directory
294294 mkdir -p artifacts
0 commit comments