]> git.seodisparate.com - TurnBasedMinecraftMod/commitdiff
Action: Check if release exists before releasing
authorStephen Seo <seo.disparate@gmail.com>
Mon, 22 Jan 2024 09:26:21 +0000 (18:26 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Mon, 22 Jan 2024 09:29:29 +0000 (18:29 +0900)
.forgejo/workflows/build-jar.yaml

index 7adf2de53b662cef6c440422f1a8e8ed34ae169f..f554559191cc4a563cbda3c4a5f46c8a23ade00d 100644 (file)
@@ -5,7 +5,20 @@ on:
       - '*'
 
 jobs:
+  check-release-exists:
+    runs-on: any_archLinux
+    outputs:
+      status: ${{ steps.release_exists_check.outputs.http_code }}
+    steps:
+      - name: Check if release already exists
+        id: release_exists_check
+        run: |
+          curl -X GET "https://git.seodisparate.com/api/v1/repos/stephenseo/TurnBasedMinecraftMod/releases/tags/${GITHUB_REF_NAME}" \
+          -H 'accept: application/json' -o release_check_resp.json 2>/dev/null \
+          -w '%{http_code}\n' | sed 's/^\([0-9]\+\)/http_code=\1/' >> "$GITHUB_OUTPUT"
   build-and-create-release:
+    needs: check-release-exists
+    if: ${{ needs.check-release-exists.outputs.status == '404' }}
     runs-on: any_archLinux
     steps:
       - run: git clone --depth=1 --no-single-branch https://git.seodisparate.com/stephenseo/TurnBasedMinecraftMod.git TurnBasedMinecraftMod