Просмотр исходного кода

fix: Update API call to check for specific release tag

The Github API call in the workflow has been updated to specifically check if the required release tag exists before making a POST request. This avoids unnecessary API calls and prevents potential issues in case the tag does not exist. The changes are made in the build-with-firmware.yml file for the 'Subbrute' application.
DerSkythe 2 лет назад
Родитель
Сommit
65646825f0
1 измененных файлов с 7 добавлено и 3 удалено
  1. 7 3
      .github/workflows/build-with-firmwware.yml

+ 7 - 3
.github/workflows/build-with-firmwware.yml

@@ -191,10 +191,14 @@ jobs:
         env:
           GITHUB_TOKEN: ${{ secrets.FLIPPER_TOKEN }}
         run: |
-          $url = (gh api -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.REPOSITORY }}/releases/tags/v${{ env.RELEASE_VERSION }} >$null 2>&1) | ConvertFrom-Json -AsHashtable -ErrorAction SilentlyContinue
-          if ( [string]::IsNullOrWhitespace($url.name) ) {
+          $mime = "Accept: application/vnd.github+json"
+          $api = "X-GitHub-Api-Version: 2022-11-28"
+          #$url = (gh api -H $mime -H $api /repos/${{ github.REPOSITORY }}/releases/tags/v${{ env.RELEASE_VERSION }} >$null 2>&1) | ConvertFrom-Json -AsHashtable -ErrorAction SilentlyContinue
+          $json = (gh api -H $mime -H $api /repos/${{ github.REPOSITORY }}/releases) | ConvertFrom-Json
+          $tagExists = ($json.GetEnumerator() | Where-Object { $_.tag_name -eq 'v3.19.2' }) -ne $null
+          if ( $tagExists -eq $true ) {
             $sha = (git rev-parse --verify HEAD)
-            gh api --method POST -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" /repos/${{ github.REPOSITORY }}/releases -f tag_name='v${{ env.RELEASE_VERSION }}' -f target_commitish="$sha" -f name='v${{ env.RELEASE_VERSION }}' -F draft=true -F prerelease=false -F generate_release_notes=true
+            gh api --method POST -H $mime -H $api /repos/${{ github.REPOSITORY }}/releases -f tag_name='v${{ env.RELEASE_VERSION }}' -f target_commitish="$sha" -f name='v${{ env.RELEASE_VERSION }}' -F draft=true -F prerelease=false -F generate_release_notes=true
             #gh release create v${{ env.RELEASE_VERSION }} --generate-notes -f target_commitish='master' --draft -R ${{ env.REPO_SELF }}  
           }          
           gh release upload 'v${{ env.RELEASE_VERSION }}' '${{ env.ZIP_NAME }}#${{ env.ZIP_TAG }}' '${{ env.TGZ_NAME }}#${{ env.TGZ_TAG }}' --clobber -R ${{ env.REPO_SELF }}