From 936b67f3457134fe2453ca349e46b87ac49e1365 Mon Sep 17 00:00:00 2001 From: Erisa A Date: Tue, 1 Oct 2024 20:03:00 +0100 Subject: [PATCH] try using bash to check default branch --- .github/workflows/docker.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 1b59e7c..6675817 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -27,6 +27,14 @@ jobs: steps: - name: Check out code uses: actions/checkout@v4 + + - name: Set default branch variable + run : | + if [[ $GITHUB_REF_NAME == 'main' ]]; then + echo "IS_MAIN_BRANCH=true" >> "$GITHUB_ENV" + else + echo "IS_MAIN_BRANCH=false" >> "$GITHUB_ENV" + fi - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -61,7 +69,7 @@ jobs: labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha,scope=ubicloud-${{ matrix.runner }} cache-to: type=gha,mode=max,scope=ubicloud-${{ matrix.runner }} - outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest={{is_default_branch}},name-canonical={{is_default_branch}},push={{is_default_branch}} + outputs: type=image,name=${{ env.IMAGE_NAME }},push-by-digest=${{env.IS_MAIN_BRANCH}},name-canonical=${{env.IS_MAIN_BRANCH}},push=${{env.IS_MAIN_BRANCH}} provenance: false - name: Export digest