diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index a1dce53..51df2bc 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -132,3 +132,49 @@ jobs: env: GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }} run: goreleaser release --clean + + docker: + name: Build & Push Docker Image + runs-on: ubuntu-latest + needs: [test, lint] + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/')) + container: + image: docker:24-cli + options: --privileged + services: + docker: + image: docker:24-dind + options: --privileged + steps: + - name: Install dependencies + run: apk add --no-cache git curl + + - name: Checkout code + run: | + git config --global --add safe.directory "$GITHUB_WORKSPACE" + git clone --depth 1 --branch ${GITHUB_REF_NAME} ${{ env.GITEA_URL }}/${GITHUB_REPOSITORY}.git . + + - name: Set up Docker Buildx + run: | + docker buildx create --use --name builder --driver docker-container + docker buildx inspect --bootstrap + + - name: Login to Gitea Registry + run: | + echo "${{ secrets.REGISTRY_TOKEN }}" | docker login git.uuxo.net -u "${{ secrets.REGISTRY_USER }}" --password-stdin + + - name: Build and push + run: | + # Determine tags + if [[ "${GITHUB_REF}" == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + TAGS="-t git.uuxo.net/uuxo/dbbackup:${VERSION} -t git.uuxo.net/uuxo/dbbackup:latest" + else + TAGS="-t git.uuxo.net/uuxo/dbbackup:${GITHUB_SHA::8} -t git.uuxo.net/uuxo/dbbackup:main" + fi + + docker buildx build \ + --platform linux/amd64,linux/arm64 \ + --push \ + ${TAGS} \ + .