diff --git a/.github/workflows/build_and_push_ghcr.yml b/.github/workflows/build_and_push_ghcr.yml deleted file mode 100644 index 7c3e5da..0000000 --- a/.github/workflows/build_and_push_ghcr.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: Build a Docker image and push it to the GitHub container registry - -on: - push: - branches: [ 'main' ] - tags: [ '*.*.*' ] - -jobs: - build: - runs-on: ubuntu-latest - permissions: - contents: read - packages: write - id-token: write - - steps: - # https://github.com/actions/checkout - - name: Checkout repository - uses: actions/checkout@v3 - - # https://github.com/sigstore/cosign-installer - - name: Install cosign - if: github.event_name != 'pull_request' - uses: sigstore/cosign-installer@main - with: - cosign-release: 'v2.0.1' - - # https://github.com/docker/setup-buildx-action - - name: Set up Docker buildx - uses: docker/setup-buildx-action@v2 - - # https://github.com/docker/login-action - - name: Log into ghcr.io - if: github.event_name != 'pull_request' - uses: docker/login-action@v2 - with: - registry: ghcr.io - username: ${{ github.actor }} - password: ${{ secrets.GITHUB_TOKEN }} - - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta - uses: docker/metadata-action@v4 - with: - images: ghcr.io/${{ github.repository }} - - # https://github.com/docker/build-push-action - - name: Build and push Docker image - id: build-and-push - uses: docker/build-push-action@v4 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max - - # https://github.com/sigstore/cosign - - name: Sign the published Docker image - if: github.event_name != 'pull_request' - env: - COSIGN_EXPERIMENTAL: "true" - run: echo "${{ steps.meta.outputs.tags }}" | xargs -I {} cosign sign -y {}@${{ steps.build-and-push.outputs.digest }} - - # https://github.com/docker/login-action - - name: Log into Docker Hub - if: github.event_name != 'pull_request' - uses: docker/login-action@v1 - with: - registry: docker.io - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - # https://github.com/docker/metadata-action - - name: Extract Docker metadata - id: meta-docker - uses: docker/metadata-action@v4 - with: - images: docker.io/${{ secrets.DOCKERHUB_IMAGE_NAME }} - - # https://github.com/docker/build-push-action - - name: Build and push Docker image to Docker Hub - if: github.event_name != 'pull_request' - uses: docker/build-push-action@v2 - with: - context: . - push: ${{ github.event_name != 'pull_request' }} - tags: ${{ steps.meta-docker.outputs.tags }} - labels: ${{ steps.meta-docker.outputs.labels }} diff --git a/.github/workflows/build_and_push_to_docker_hub.yml b/.github/workflows/build_and_push_to_docker_hub.yml new file mode 100644 index 0000000..6897bcb --- /dev/null +++ b/.github/workflows/build_and_push_to_docker_hub.yml @@ -0,0 +1,43 @@ +name: Build Docker image and push to Docker Hub + +on: + push: + branches: [ 'main' ] + tags: [ '*.*.*' ] + +jobs: + build: + name: Build a new Docker image for the release (and a latest) and push it to Docker Hub + runs-on: ubuntu-latest + + steps: + # https://github.com/actions/checkout + - name: Checkout repository + uses: actions/checkout@v4 + + # https://github.com/docker/login-action + - name: Log into Docker Hub + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: docker.io + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_PASSWORD }} + + # https://github.com/docker/metadata-action + - name: Extract Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + images: docker.io/${{ secrets.DOCKERHUB_IMAGE_NAME }} + + # https://github.com/docker/build-push-action + - name: Build and push Docker image + if: github.event_name != 'pull_request' + id: build-and-push + uses: docker/build-push-action@v5 + with: + context: . + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}