diff --git a/.gitea/workflows/build.yaml b/.gitea/workflows/build.yaml index 324c257..20cf4d8 100644 --- a/.gitea/workflows/build.yaml +++ b/.gitea/workflows/build.yaml @@ -15,13 +15,7 @@ jobs: - name: Install dependencies shell: sh run: | - apk add --no-cache git wget ca-certificates - - - name: Install Kaniko - shell: sh - run: | - wget -O /usr/local/bin/executor https://github.com/GoogleContainerTools/kaniko/releases/download/v1.23.2/executor-linux-amd64 - chmod +x /usr/local/bin/executor + apk add --no-cache git buildah fuse-overlayfs - name: Checkout code shell: sh @@ -48,54 +42,47 @@ jobs: IMAGE_BASE="${REGISTRY}/${REPO_OWNER_LOWER}/${REPO_NAME_LOWER}" # Determine tag based on ref - if [[ "${{ gitea.ref }}" == refs/tags/* ]]; then - # Tag push - use the tag name - TAG_NAME="${{ gitea.ref_name }}" - echo "IMAGE_TAG=${IMAGE_BASE}:${TAG_NAME}" >> $GITHUB_OUTPUT - echo "PUSH_LATEST=true" >> $GITHUB_OUTPUT - elif [[ "${{ gitea.ref_name }}" == "main" ]]; then - # Main branch - use commit SHA (shortened to 7 chars) and latest - SHORT_SHA=$(echo "${{ gitea.sha }}" | cut -c1-7) - echo "IMAGE_TAG=${IMAGE_BASE}:${SHORT_SHA}" >> $GITHUB_OUTPUT - echo "PUSH_LATEST=true" >> $GITHUB_OUTPUT - else - # Other branches - use branch name - BRANCH_TAG=$(echo "${{ gitea.ref_name }}" | sed 's/\//-/g') - echo "IMAGE_TAG=${IMAGE_BASE}:${BRANCH_TAG}" >> $GITHUB_OUTPUT - echo "PUSH_LATEST=false" >> $GITHUB_OUTPUT - fi + case "${{ gitea.ref }}" in + refs/tags/*) + # Tag push - use the tag name + TAG_NAME="${{ gitea.ref_name }}" + echo "IMAGE_TAG=${IMAGE_BASE}:${TAG_NAME}" >> $GITHUB_OUTPUT + echo "PUSH_LATEST=true" >> $GITHUB_OUTPUT + ;; + refs/heads/main) + # Main branch - use commit SHA (shortened to 7 chars) and latest + SHORT_SHA=$(echo "${{ gitea.sha }}" | cut -c1-7) + echo "IMAGE_TAG=${IMAGE_BASE}:${SHORT_SHA}" >> $GITHUB_OUTPUT + echo "PUSH_LATEST=true" >> $GITHUB_OUTPUT + ;; + *) + # Other branches - use branch name + BRANCH_TAG=$(echo "${{ gitea.ref_name }}" | sed 's/\//-/g') + echo "IMAGE_TAG=${IMAGE_BASE}:${BRANCH_TAG}" >> $GITHUB_OUTPUT + echo "PUSH_LATEST=false" >> $GITHUB_OUTPUT + ;; + esac echo "IMAGE_LATEST=${IMAGE_BASE}:latest" >> $GITHUB_OUTPUT - - name: Setup Kaniko config + - name: Login to registry shell: sh run: | - mkdir -p /kaniko/.docker - cat > /kaniko/.docker/config.json <