name: docker-image
on: 
  release:
    types: [published]
jobs:
  build-and-push:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Set up QEMU
        uses: docker/setup-qemu-action@v3
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
      - name: Login to DockerHub
        uses: docker/login-action@v3 
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_TOKEN }}
      - name: Get the tag name
        run: echo "TAG=${GITHUB_REF/refs\/tags\//}" >> $GITHUB_ENV
      - name: Build and push Docker images
        uses: docker/build-push-action@v5.1.0
        with:
          context: .
          push: true
          platforms: linux/amd64,linux/arm64,linux/s390x
          tags: antonyleons/ward:latest,antonyleons/ward:${{ env.TAG }}