Unverified Commit 53e972c3 authored by Yifan Xiong's avatar Yifan Xiong Committed by GitHub
Browse files

CI/CD - Fix bug in build image for push event (#205)

Fix bug in build image for push event.

**Major Revision**
- Fix bug in build image for push event when `github.base_ref` is not set.

**Minor Revision**
- Unify `[` and `[[` usage.
parent e80447f7
...@@ -47,25 +47,25 @@ jobs: ...@@ -47,25 +47,25 @@ jobs:
id: metadata id: metadata
run: | run: |
TAGS=${{ matrix.tags }} TAGS=${{ matrix.tags }}
if [ "${{ github.event_name }}" == "push" ] && [[ ${{ github.ref }} == refs/heads/release/* ]]; then if [[ "${{ github.event_name }}" == "push" ]] && [[ "${{ github.ref }}" == "refs/heads/release/"* ]]; then
TAGS=$(sed "s/main:/release:${GITHUB_REF##*/}-/g" <<< ${TAGS}) TAGS=$(sed "s/main:/release:${GITHUB_REF##*/}-/g" <<< ${TAGS})
fi fi
if [ "${{ github.event_name }}" == "pull_request" ] && [[ ${{ github.base_ref }} == release/* ]]; then if [[ "${{ github.event_name }}" == "pull_request" ]] && [[ "${{ github.base_ref }}" == "release/"* ]]; then
TAGS=$(sed "s/main:/release:${GITHUB_BASE_REF##*/}-/g" <<< ${TAGS}) TAGS=$(sed "s/main:/release:${GITHUB_BASE_REF##*/}-/g" <<< ${TAGS})
fi fi
if [ "${{ github.event_name }}" == "release" ]; then if [[ "${{ github.event_name }}" == "release" ]]; then
TAGS=$(sed "s/main:/superbench:${GITHUB_REF##*/}-/g" <<< ${TAGS}) TAGS=$(sed "s/main:/superbench:${GITHUB_REF##*/}-/g" <<< ${TAGS})
GHCR_TAG=$(cut -d, -f1 <<< ${TAGS} | sed "s#superbench/superbench#ghcr.io/${{ github.repository }}/superbench#g") GHCR_TAG=$(cut -d, -f1 <<< ${TAGS} | sed "s#superbench/superbench#ghcr.io/${{ github.repository }}/superbench#g")
TAGS="${TAGS},${GHCR_TAG}" TAGS="${TAGS},${GHCR_TAG}"
fi fi
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
TAGS=$(sed "s/main:/dev:/g" <<< ${TAGS}) TAGS=$(sed "s/main:/dev:/g" <<< ${TAGS})
fi fi
DOCKERFILE=dockerfile/${{ matrix.name }}.dockerfile DOCKERFILE=dockerfile/${{ matrix.name }}.dockerfile
CACHE_FROM="type=registry,ref=$(cut -d, -f1 <<< ${TAGS})" CACHE_FROM="type=registry,ref=$(cut -d, -f1 <<< ${TAGS})"
CACHE_TO="" CACHE_TO=""
if [ "${{ github.event_name }}" != "pull_request" ]; then if [[ "${{ github.event_name }}" != "pull_request" ]]; then
CACHE_TO="type=inline,mode=max" CACHE_TO="type=inline,mode=max"
fi fi
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment