version: "1"
name: Publish Docker Image
on:
  push:
    tags:
      - "v[0-9]+\\.[0-9]+\\.[0-9]+"

jobs:
  build:
    name: Publish Docker Image
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v2

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

      - name: Login to Registry
        run: echo "${{ secrets.ACCESS_TOKEN }}" | docker login git.altaiar.dev -u "${{ secrets.USERNAME }}" --password-stdin

      - name: Build & Tag Image
        run: |
          docker build -t git.altaiar.dev/${{ gitea.repository }}:${{ gitea.ref_name }} .
          docker tag git.altaiar.dev/${{ gitea.repository }}:${{ gitea.ref_name }} git.altaiar.dev/${{ gitea.repository }}:latest

      - name: Push Images
        run: |
          docker push git.altaiar.dev/${{ gitea.repository }}:${{ gitea.ref_name }}
          docker push git.altaiar.dev/${{ gitea.repository }}:latest
