This is an automated email from the ASF dual-hosted git repository.

zhongxjian pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-kubernetes.git


The following commit(s) were added to refs/heads/master by this push:
     new edc9e02f fix workflow if exist release
edc9e02f is described below

commit edc9e02f487a220fb1a407c9c29715624079dc37
Author: mfordjody <[email protected]>
AuthorDate: Sun Jun 1 08:36:58 2025 +0800

    fix workflow if exist release
---
 .github/workflows/dubbo-cp-release.yaml | 20 ++++++++++++++++++++
 .github/workflows/dubboctl-release.yaml | 20 ++++++++++++++++++++
 2 files changed, 40 insertions(+)

diff --git a/.github/workflows/dubbo-cp-release.yaml 
b/.github/workflows/dubbo-cp-release.yaml
index e4a5d995..b1931597 100644
--- a/.github/workflows/dubbo-cp-release.yaml
+++ b/.github/workflows/dubbo-cp-release.yaml
@@ -31,8 +31,28 @@ jobs:
       upload_url: ${{ steps.create_release.outputs.upload_url }}
 
     steps:
+      - name: Check if Release Exists
+        id: check
+        uses: actions/github-script@v7
+        with:
+          result-encoding: string
+          script: |
+            const tag = context.ref.replace('refs/tags/', '');
+            try {
+              await github.rest.repos.getReleaseByTag({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                tag: tag,
+              });
+              return "exists";
+            } catch (e) {
+              if (e.status === 404) return "not_found";
+              throw e;
+            }
+
       - name: Create GitHub Release
         id: create_release
+        if: steps.check.outputs.result == 'not_found'
         uses: actions/create-release@v1
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.github/workflows/dubboctl-release.yaml 
b/.github/workflows/dubboctl-release.yaml
index 006d0789..29eaae17 100644
--- a/.github/workflows/dubboctl-release.yaml
+++ b/.github/workflows/dubboctl-release.yaml
@@ -31,8 +31,28 @@ jobs:
       upload_url: ${{ steps.create_release.outputs.upload_url }}
 
     steps:
+      - name: Check if Release Exists
+        id: check
+        uses: actions/github-script@v7
+        with:
+          result-encoding: string
+          script: |
+            const tag = context.ref.replace('refs/tags/', '');
+            try {
+              await github.rest.repos.getReleaseByTag({
+                owner: context.repo.owner,
+                repo: context.repo.repo,
+                tag: tag,
+              });
+              return "exists";
+            } catch (e) {
+              if (e.status === 404) return "not_found";
+              throw e;
+            }
+
       - name: Create GitHub Release
         id: create_release
+        if: steps.check.outputs.result == 'not_found'
         uses: actions/create-release@v1
         env:
           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Reply via email to