diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 052aa01..14f4e14 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -14,6 +14,7 @@ jobs: docker: name: Docker runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v2 @@ -26,16 +27,16 @@ jobs: uses: actions/cache@v2 with: path: /tmp/.buildx-cache - key: ${{ runner.os }}-buildx-${{ github.ref }} + key: ${{ runner.os }}-buildx-${{ matrix.goarch }}-${{ github.ref }} restore-keys: | - ${{ runner.os }}-buildx- + ${{ runner.os }}-buildx-${{ matrix.goarch }}- - name: Login to GitHub Container Registry uses: docker/login-action@v2 with: registry: ghcr.io username: ${{ github.repository_owner }} - password: ${{ secrets.CR_PAT }} + password: ${{ secrets.GITHUB_TOKEN }} - name: Login to DockerHub uses: docker/login-action@v2 @@ -43,18 +44,16 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Determine tag or commit - uses: haya14busa/action-cond@v1 - id: refortag + - name: Docker meta for thanos-operator + id: thanos-operator-meta + uses: docker/metadata-action@v4 with: - cond: ${{ startsWith(github.ref, 'refs/tags/') }} - if_true: ${{ github.ref }} - if_false: latest - - name: Determine image tag - id: imagetag - run: echo "::set-output name=value::${TAG_OR_BRANCH##*/}" - env: - TAG_OR_BRANCH: ${{ steps.refortag.outputs.value }} + images: | + ghcr.io/${{ github.repository_owner }}/thanos-operator + banzaicloud/thanos-operator + tags: | + type=raw,value=latest,enable={{is_default_branch}} + - name: Build thanos-operator uses: docker/build-push-action@v3 with: @@ -63,8 +62,5 @@ jobs: push: true cache-from: type=local,src=/tmp/.buildx-cache cache-to: type=local,dest=/tmp/.buildx-cache - tags: | - ghcr.io/banzaicloud/thanos-operator:${{ steps.imagetag.outputs.value }} - banzaicloud/thanos-operator:${{ steps.imagetag.outputs.value }} - - + tags: ${{ steps.thanos-operator-meta.outputs.tags }} + labels: ${{ steps.thanos-operator-meta.outputs.labels }} diff --git a/Dockerfile b/Dockerfile index 8367131..90e9d5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,7 @@ COPY controllers/ controllers/ COPY pkg/ pkg/ # Build -RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -o manager main.go +RUN CGO_ENABLED=0 GOOS=linux GO111MODULE=on go build -a -o manager main.go # Use distroless as minimal base image to package the manager binary # Refer to https://github.com/GoogleContainerTools/distroless for more details