
name: Publish
run-name: ${{ gitea.actor }} is runs ci pipeline
#on:
#  release:
#    types: [published]
on:
  push:
    branches:
      - release/*

jobs:
#  test:
#    runs-on: ubuntu-latest
#    steps:
#      - run: echo "The release ${{ gitea.ref }} ${{ gitea.ref_name }} was published"
  
  build:
    runs-on: ubuntu-latest
#    if: gitea.ref == 'refs/heads/main'
    steps:
      - uses: https://github.com/actions/checkout@v4
  
  publish:
    runs-on: ubuntu-latest
    needs: build
    #if: gitea.ref == 'refs/heads/main'
    steps:
      - uses: https://github.com/actions/checkout@v4
      - name: Set env
        run: echo "RELEASE_VERSION=${gitea.ref_name#release/}" >> gitea.env
      - name: Test
        run: |
          echo $RELEASE_VERSION
          echo ${{ env.RELEASE_VERSION }}
      - name: Set up Docker Buildx
        uses: https://github.com/docker/setup-buildx-action@v3
        with:
          config-inline: |
            [registry."gitea.sanplex.tech/sansan"]
              http = true
              insecure = true            
      - name: Login to Gitea
        uses: docker/login-action@v2
        with:
          registry: gitea.sanplex.tech
          username: ${{ github.repository_owner }}
          password: ${{ secrets.TOKEN }}
      - name: Build and push Docker image
        uses: https://github.com/docker/build-push-action@v5
        with:
          context: .
          file: ./Dockerfile
          push: true
          tags: "gitea.sanplex.tech/sansan/musicserver:${{gitea.ref_name}}, gitea.sanplex.tech/sansan/musicserver:latest"
