name: docker-deployment

on:
    push:
        branches:
            - main
        paths-ignore:
            - '**.md'
            - 'docs/**'

jobs:
    docker:
        runs-on: ubuntu-latest
        steps:
            - name: Checkout
              uses: actions/checkout@v4

            - name: Login to Docker Hub
              uses: docker/login-action@v3
              with:
                  username: ${{ vars.DOCKERHUB_USERNAME }}
                  password: ${{ secrets.DOCKERHUB_TOKEN }}

            - name: Set up QEMU
              uses: docker/setup-qemu-action@v3

            - name: Set up Docker Buildx
              uses: docker/setup-buildx-action@v3

            - name: Extract short SHA
              id: sha
              run: echo "sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT

            - name: Build and push
              uses: docker/build-push-action@v6
              with:
                  context: .
                  file: ./apps/open-archiver/Dockerfile
                  platforms: linux/amd64,linux/arm64
                  push: true
                  tags: logiclabshq/open-archiver:${{ steps.sha.outputs.sha }}
