diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2dd72b6..7b94517 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,24 +1,51 @@ -name: Publish +name: Create and publish Docker image on ghcr.io on: push: branches: - main +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + jobs: - docker-publish: - name: Publish to Docker Hub - runs-on: ubuntu-20.04 + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + steps: - - name: Checkout code - uses: actions/checkout@v2 - - name: Login to DockerHub - uses: docker/login-action@v1 + - name: Checkout repository + uses: actions/checkout@v4 + + # https://github.com/docker/setup-qemu-action + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + # https://github.com/docker/setup-buildx-action + - name: Set up Docker Buildx + id: buildx + uses: docker/setup-buildx-action@v3 + + - name: Log in to the Container registry + uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Build and push - uses: docker/build-push-action@v2 + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Build and push Docker image + uses: docker/build-push-action@v5 with: + context: . + platforms: linux/amd64,linux/arm64,linux/arm/v7 push: true - tags: dchesterton/amcrest2mqtt:latest \ No newline at end of file + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}