name: Build & Push Docker Image

on:
  push:
    branches: [main, master]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        run: |
          cd /tmp
          rm -rf kv-tube
          git clone https://vndangkhoa:b14bc4938aeb5f4014fa15186985a0a625f7e9b4@nas:3050/vndangkhoa/kv-tube.git
          cd kv-tube
          git checkout ${GITEA_SHA:-main}

      - name: Build and push
        run: |
          cd /tmp/kv-tube
          SHA_SHORT=$(git rev-parse --short HEAD)
          IMAGE="git.khoavo.myds.me/vndangkhoa/kv-tube"
          docker build -t ${IMAGE}:${SHA_SHORT} .
          docker push ${IMAGE}:${SHA_SHORT}
