Skip to content

Commit 73c146a

Browse files
fix(docker): use GITHUB_* env vars and push detection (#614)
1 parent cdf5cf1 commit 73c146a

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

.github/workflows/__call-docker.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,24 +161,27 @@ jobs:
161161
BRANCH: ${{ github.ref }}
162162
COMMIT: ${{ inputs.release_commit }}
163163
NEW_TAG: ${{ inputs.release_tag }}
164+
GH_EVENT_REPOSITORY_CLONE_URL: ${{ github.event.repository.clone_url }}
164165
shell: bash
165166
run: |
166167
# get variables
167168
branch="${BRANCH:-master}"
168-
commit="${COMMIT:-${{ github.sha }}}"
169-
clone_url="${{ github.event.repository.clone_url }}"
169+
commit="${COMMIT:-${GITHUB_SHA}}"
170+
clone_url="${GH_EVENT_REPOSITORY_CLONE_URL}"
170171
171-
if [ "${{ github.event_name }}" == "push" ]; then
172+
push=false
173+
if [ "${GITHUB_EVENT_NAME}" == "push" ]; then
172174
echo "This is a PUSH event"
173-
branch="${{ github.ref_name }}"
175+
branch="${GITHUB_REF_NAME}"
176+
push=true
174177
fi
175178
176179
# setup the tags
177180
BASE_TAG="${{ needs.check_dockerfiles.outputs.base_tag }}"
178181
179182
TAGS="${BASE_TAG}:${commit:0:7}${{ matrix.tag }},ghcr.io/${BASE_TAG}:${commit:0:7}${{ matrix.tag }}"
180183
181-
if [[ "${branch}" == refs/heads/master ]]; then
184+
if [[ "${push}" == true ]]; then
182185
TAGS="${TAGS},${BASE_TAG}:latest${{ matrix.tag }},ghcr.io/${BASE_TAG}:latest${{ matrix.tag }}"
183186
TAGS="${TAGS},${BASE_TAG}:master${{ matrix.tag }},ghcr.io/${BASE_TAG}:master${{ matrix.tag }}"
184187
else
@@ -192,7 +195,7 @@ jobs:
192195
# parse custom directives out of dockerfile
193196
# try to get the platforms from the dockerfile custom directive, i.e. `# platforms: xxx,yyy`
194197
# directives for PR event, i.e. not push event
195-
if [ "${{ github.event_name }}" == "pull_request" ]; then
198+
if [ "${GITHUB_EVENT_NAME}" == "pull_request" ]; then
196199
while read -r line; do
197200
if [[ $line == "# platforms_pr: "* && $PLATFORMS == "" ]]; then
198201
# echo the line and use `sed` to remove the custom directive

0 commit comments

Comments
 (0)