diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 1ebcebf..2a04965 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,5 +1,13 @@ name: Run Tests -on: [push, pull_request, create] +on: + push: + branches: + - 'master' + tags: + - '*' + pull_request: + branches: + - '*' jobs: runTests: runs-on: ubuntu-latest @@ -7,6 +15,10 @@ jobs: - uses: actions/checkout@v2 with: submodules: 'recursive' + - name: Set up QEMU + uses: docker/setup-qemu-action@v1 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 - uses: actions/setup-java@v2 with: distribution: 'adopt' @@ -17,8 +29,26 @@ jobs: run: | mvn package ./src/test/resources/run-s3-tests.sh - - name: Build Docker Image - run: ./publish_img.sh - env: - DOCKER_USER: ${{ secrets.DOCKER_USER }} - DOCKER_PASS: ${{ secrets.DOCKER_PASS }} \ No newline at end of file + - name: Login to DockerHub + uses: docker/login-action@v1 + if: github.event_name != 'pull_request' + with: + username: ${{ secrets.DOCKER_USER }} + password: ${{ secrets.DOCKER_PASS }} + - name: Docker meta + id: meta + uses: docker/metadata-action@v3 + with: + images: andrewgaul/s3proxy + tags: | + type=sha,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} \ No newline at end of file diff --git a/publish_img.sh b/publish_img.sh deleted file mode 100755 index dfb82d2..0000000 --- a/publish_img.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -set -o nounset -set -o pipefail - -REPO=andrewgaul/s3proxy - -docker login -u "$DOCKER_USER" -p "$DOCKER_PASS" docker.io -docker buildx build --platform linux/amd64 -t $REPO:latest . - -if [[ "$GITHUB_EVENT_NAME" == "push" && $GITHUB_REF == refs/heads/master ]]; then - docker tag $REPO:latest $REPO:${GITHUB_SHA::8} - docker push --all-tags $REPO -elif [[ "$GITHUB_EVENT_NAME" == "create" && $GITHUB_REF == refs/tags/* ]]; then - docker tag $REPO:latest $REPO:${GITHUB_REF#refs/tags/} - docker push --all-tags $REPO -fi