diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 0c46e3d..5d50ab6 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -10,7 +10,7 @@ on: jobs: build-deploy: runs-on: self-hosted - if: ${{ github.event_name != 'pull_request' || github.event.pull_request.merged == true }} + if: ${{ github.event.pull_request.merged == true }} steps: - name: Set up environment run: | @@ -30,7 +30,7 @@ jobs: create-release: runs-on: self-hosted needs: build-deploy - if: ${{ success() && github.ref == 'refs/heads/master' }} + if: ${{ success() && github.event.pull_request.merged == true && github.event.pull_request.base.ref == 'master' }} steps: - name: Create release env: @@ -40,13 +40,22 @@ jobs: RELEASE_TAG: ci-${{ github.run_id }} RELEASE_TARGET: ${{ github.sha }} run: | - if (-not $env:GITEA_TOKEN) { throw "Missing secrets.GITEA_TOKEN" } - $apiUrl = "$($env:GITEA_SERVER_URL)/api/v1/repos/$($env:GITEA_REPOSITORY)/releases" - $body = @{ - tag_name = $env:RELEASE_TAG - name = $env:RELEASE_TAG - target_commitish = $env:RELEASE_TARGET - draft = $false - prerelease = $false - } | ConvertTo-Json - Invoke-RestMethod -Method Post -Uri $apiUrl -Headers @{ Authorization = "token $($env:GITEA_TOKEN)" } -Body $body -ContentType "application/json" + if [ -z "$GITEA_TOKEN" ]; then + echo "Missing secrets.RUNNER_TOKEN" + exit 1 + fi + api_url="$GITEA_SERVER_URL/api/v1/repos/$GITEA_REPOSITORY/releases" + payload=$(cat <