diff --git a/.github/workflows/build_and_push_image.yml b/.github/workflows/build_and_push_image.yml index 78544fbe..409dad1d 100644 --- a/.github/workflows/build_and_push_image.yml +++ b/.github/workflows/build_and_push_image.yml @@ -10,15 +10,31 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: agilepathway/pull-request-label-checker + tags: | + type=ref,event=branch + type=sha - name: Build and push Docker image # Skip running on forks or Dependabot since neither has access to secrets if: | (github.repository == 'agilepathway/label-checker') && (github.actor!= 'dependabot[bot]') && (contains(github.head_ref, 'dependabot/github_actions/') == false) - uses: docker/build-push-action@v1.1.0 + uses: docker/build-push-action@v5 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - repository: agilepathway/pull-request-label-checker - tag_with_ref: true + tags: ${{ steps.meta.outputs.tags }} + push: true + platforms: linux/amd64,linux/arm64 diff --git a/.github/workflows/github_tag_and_release.yml b/.github/workflows/github_tag_and_release.yml index 15e60ff4..a39de165 100644 --- a/.github/workflows/github_tag_and_release.yml +++ b/.github/workflows/github_tag_and_release.yml @@ -53,9 +53,18 @@ jobs: runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - - uses: docker/build-push-action@v1.1.0 + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + - name: Login to Docker Hub + uses: docker/login-action@v2 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - repository: agilepathway/pull-request-label-checker - tags: ${{ needs.tag.outputs.tag }} + - name: Build and push Docker image + uses: docker/build-push-action@v5 + with: + tags: agilepathway/pull-request-label-checker:${{ needs.tag.outputs.tag }} + platforms: linux/amd64,linux/arm64 + push: true diff --git a/Dockerfile b/Dockerfile index 398104d5..3485267e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.21.1-bullseye AS builder WORKDIR /src COPY . . -RUN CGO_ENABLED=0 GOFLAGS=-ldflags="-w" GOOS=linux GOARCH=amd64 go build -o /bin/check-labels label_checker.go \ +RUN CGO_ENABLED=0 GOFLAGS=-ldflags="-w" GOOS=linux GOARCH=${BUILDARCH} go build -o /bin/check-labels label_checker.go \ # Strip any symbols - this is not a library && strip /bin/check-labels \ # Compress the compiled action using UPX (https://upx.github.io/)