# https://docs.gitea.com/usage/actions/overview
# https://docs.github.com/ru/actions/reference/workflows-and-actions/contexts

name: Build images

on:
  push:
    branches:
      - 'master'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
        with: # https://github.com/actions/checkout
          fetch-depth: 0

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v3
        with: # https://github.com/docker/setup-buildx-action
          buildkitd-config-inline: |
            # https://github.com/moby/buildkit/blob/master/docs/buildkitd.toml.md
            [ registry."docker.io" ]
            mirrors = ["https://dockerhub.timeweb.cloud", "https://dh-mirror.gitverse.ru"]
            http = true
            insecure = true

      - name: Log in to Gitea Container Registry
        uses: docker/login-action@v3
        with: # https://github.com/docker/login-action
          registry: git.axenov.dev
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.RELEASE_TOKEN }}

      - name: Build and push Docker images
        uses: docker/build-push-action@v5
        with: # https://github.com/docker/build-push-action
          context: .
          push: true
          tags: |
            git.axenov.dev/iptv/m3u-su-docs:${{ github.ref_name }}
            git.axenov.dev/iptv/m3u-su-docs:latest
