diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index d0b5c71f2..76a59eef5 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,7 +3,7 @@ name: Docker Workflow on: push: tags: ['v*.*.*'] - + branches: [master] pull_request: branches: [master] @@ -15,8 +15,21 @@ env: jobs: build: + name: Build Docker Image + runs-on: ubuntu-latest + if: github.event_name == 'pull_request' + permissions: + contents: read + steps: + - name: Repository Checkout + uses: actions/checkout@v3 + + - name: Build Docker Image + run: docker build . -t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} + push: name: Build & Push Docker Image runs-on: ubuntu-latest + if: github.event_name == 'push' || (github.event_name == 'workflow_call' && github.event.inputs.trigger == 'build') permissions: contents: read packages: write @@ -35,7 +48,7 @@ jobs: id: meta uses: docker/metadata-action@v3 with: - images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ github.sha }} - name: Build & Push Docker Image uses: docker/build-push-action@v4 diff --git a/.github/workflows/dockerhub.yml b/.github/workflows/dockerhub.yml index e4daee1e4..4dad53374 100644 --- a/.github/workflows/dockerhub.yml +++ b/.github/workflows/dockerhub.yml @@ -12,7 +12,7 @@ name: Dockerhub on: push: tags: ['v*.*.*'] - + branches: [master] pull_request: branches: [master] @@ -22,7 +22,8 @@ env: IMAGE_NAME: ${{ github.repository }} jobs: - docker: + push: + if: github.event_name == 'push' && github.ref == 'refs/heads/master' runs-on: ubuntu-latest steps: - @@ -41,5 +42,15 @@ jobs: name: Build and push uses: docker/build-push-action@v4 with: - push: true - tags: cyclefive/cracktunes:latest + push: ${{ github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/') }} + tags: ${{ env.IMAGE_NAME }}:${{ github.sha }} + build: + if: github.event_name == 'push' && github.ref == 'refs/heads/master' + runs-on: ubuntu-latest + steps: + - + name: Set up QEMU + uses: docker/setup-qemu-action@v2 + - + name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 \ No newline at end of file