name: Docker

on:
  push:
    paths-ignore:
      - "README.md"
    branches:
      - master

jobs:
  tests:
    uses: ./.github/workflows/run-tests.yml
  build-docker-amd64:
    needs: [tests]
    runs-on: buildjet-2vcpu-ubuntu-2204
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v2
        with:
          version: latest
      - name: Login to DockerHub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      - name: Build and push AMD64 Docker image
        uses: docker/build-push-action@v3
        with:
          context: .
          file: ./Dockerfile
          platforms: linux/amd64
          push: true
          tags: zedeus/nitter:latest,zedeus/nitter:${{ github.sha }}
  build-docker-arm64:
    needs: [tests]
    runs-on: buildjet-2vcpu-ubuntu-2204-arm
    steps:
      - uses: actions/checkout@v3
        with:
          fetch-depth: 0
      - name: Set up Docker Buildx
        id: buildx
        uses: docker/setup-buildx-action@v2
        with:
          version: latest
      - name: Login to DockerHub
        uses: docker/login-action@v2
        with:
          username: ${{ secrets.DOCKER_USERNAME }}
          password: ${{ secrets.DOCKER_PASSWORD }}
      - name: Build and push ARM64 Docker image
        uses: docker/build-push-action@v3
        with:
          context: .
          file: ./Dockerfile.arm64
          platforms: linux/arm64
          push: true
          tags: zedeus/nitter:latest-arm64,zedeus/nitter:${{ github.sha }}-arm64
