name: Publish Docker image

on:
  release:
    types: [published]

jobs:
  build-and-push-to-registry:
    name: Build and push container image
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v3
      - name: Extract metadata (tags, labels) for Docker
        id: meta
        uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a
        with:
          images: weaveworks/eksctl
      - name: Log in to Docker Hub
        uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b
        with:
          username: weaveworkseksctlci
          password: ${{ secrets.DOCKER_HUB_PASSWORD }}
      - name: Build and push Docker image
        uses: docker/build-push-action@c84f38281176d4c9cdb1626ffafcd6b3911b5d94 #3.1.1
        with:
          context: .
          push: true
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
