Skip to content

Commit a84e1ed

Browse files
authored
[APIPUB-92] - Fix the Step "Create API Publisher Pre-Release" (Ed-Fi-Alliance-OSS#94)
* Add the write permission to the Action in order to create a release in the GitHub * Add try-catch to the Create API Publisher Pre-Release step * Fix the if statement
1 parent 98c6f80 commit a84e1ed

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

.github/workflows/on-merge-or-tag.yml

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,13 @@ jobs:
2121
create-pre-releases:
2222
name: Create Pre-Releases
2323
# Was not successful filtering out alpha in on.push.tags, so try filtering at the job level
24-
if: "! contains(github.ref_name, 'alpha')"
24+
if: ${{ ! contains(github.ref_name, 'alpha') }}
2525
runs-on: ubuntu-latest
2626
defaults:
2727
run:
2828
shell: pwsh
29+
permissions:
30+
contents: write
2931
steps:
3032
- name: Checkout the Repo
3133
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
@@ -52,7 +54,7 @@ jobs:
5254
$tag = $version -replace "v","Pre-Release-v"
5355
5456
$body = @{
55-
tag_name = "$tag"
57+
tag_name = $tag
5658
target_commitish = "main"
5759
name = $version
5860
body = ""
@@ -64,6 +66,16 @@ jobs:
6466
$headers = @{
6567
Accept = "application/vnd.github+json"
6668
Authorization = "Bearer ${{ env.TOKEN }}"
69+
"X-GitHub-Api-Version" = "2022-11-28"
6770
}
6871
69-
Invoke-RestMethod -Method POST -Uri ${{ env.API_URL }}/releases -Body $body -Headers $headers
72+
try {
73+
$response = Invoke-RestMethod -Method POST -Uri "${{ env.API_URL }}/releases" -Body $body -Headers $headers -ContentType "application/json"
74+
Write-Host "Release created successfully: $($response.html_url)"
75+
}
76+
catch {
77+
Write-Host "Error creating release: $($_.Exception.Message)"
78+
Write-Host "Status Code: $($_.Exception.Response.StatusCode)"
79+
Write-Host "Response: $($_.Exception.Response)"
80+
throw
81+
}

0 commit comments

Comments
 (0)