test create-release 2
This commit is contained in:
@ -10,7 +10,7 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
build-deploy:
|
build-deploy:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.merged == true }}
|
if: ${{ github.event.pull_request.merged == true }}
|
||||||
steps:
|
steps:
|
||||||
- name: Set up environment
|
- name: Set up environment
|
||||||
run: |
|
run: |
|
||||||
@ -30,7 +30,7 @@ jobs:
|
|||||||
create-release:
|
create-release:
|
||||||
runs-on: self-hosted
|
runs-on: self-hosted
|
||||||
needs: build-deploy
|
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:
|
steps:
|
||||||
- name: Create release
|
- name: Create release
|
||||||
env:
|
env:
|
||||||
@ -40,13 +40,22 @@ jobs:
|
|||||||
RELEASE_TAG: ci-${{ github.run_id }}
|
RELEASE_TAG: ci-${{ github.run_id }}
|
||||||
RELEASE_TARGET: ${{ github.sha }}
|
RELEASE_TARGET: ${{ github.sha }}
|
||||||
run: |
|
run: |
|
||||||
if (-not $env:GITEA_TOKEN) { throw "Missing secrets.GITEA_TOKEN" }
|
if [ -z "$GITEA_TOKEN" ]; then
|
||||||
$apiUrl = "$($env:GITEA_SERVER_URL)/api/v1/repos/$($env:GITEA_REPOSITORY)/releases"
|
echo "Missing secrets.RUNNER_TOKEN"
|
||||||
$body = @{
|
exit 1
|
||||||
tag_name = $env:RELEASE_TAG
|
fi
|
||||||
name = $env:RELEASE_TAG
|
api_url="$GITEA_SERVER_URL/api/v1/repos/$GITEA_REPOSITORY/releases"
|
||||||
target_commitish = $env:RELEASE_TARGET
|
payload=$(cat <<EOF
|
||||||
draft = $false
|
{
|
||||||
prerelease = $false
|
"tag_name": "$RELEASE_TAG",
|
||||||
} | ConvertTo-Json
|
"name": "$RELEASE_TAG",
|
||||||
Invoke-RestMethod -Method Post -Uri $apiUrl -Headers @{ Authorization = "token $($env:GITEA_TOKEN)" } -Body $body -ContentType "application/json"
|
"target_commitish": "$RELEASE_TARGET",
|
||||||
|
"draft": false,
|
||||||
|
"prerelease": false
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
)
|
||||||
|
curl -sS -X POST "$api_url" \
|
||||||
|
-H "Authorization: token $GITEA_TOKEN" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-d "$payload"
|
||||||
|
|||||||
Reference in New Issue
Block a user