name: Build and Deploy on: push: branches: - main - master pull_request: branches: - main - master env: REGISTRY: gitea.shtao1.cn IMAGE_NAME: ${{ gitea.repository }} DOTNET_VERSION: '10.0' jobs: build: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Setup .NET uses: actions/setup-dotnet@v4 with: dotnet-version: ${{ env.DOTNET_VERSION }} - name: Configure NuGet run: | cat > NuGet.Config << 'NUGET' NUGET - name: Restore dependencies run: dotnet restore src/YarpGateway.csproj - name: Build run: dotnet build src/YarpGateway.csproj --configuration Release --no-restore - name: Publish run: dotnet publish src/YarpGateway.csproj --configuration Release --no-build --output ./publish docker: needs: build runs-on: ubuntu-latest if: gitea.event_name == 'push' steps: - name: Checkout uses: actions/checkout@v4 - name: Configure NuGet for Docker run: | cat > NuGet.Config << 'NUGET' NUGET - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 with: driver-opts: | image=moby/buildkit:buildx-stable-1 - name: Login to Gitea Registry uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ gitea.actor }} password: ${{ secrets.DOCKER_TOKEN }} - name: Extract metadata id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} tags: | type=ref,event=branch type=sha,prefix= type=raw,value=latest,enable={{is_default_branch}} - name: Build and push Docker image uses: docker/build-push-action@v5 with: context: . push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max deploy: