Skip to content

Commit 957363d

Browse files
authored
chore: prevent duplicate preview release comments (#119)
1 parent ef11f19 commit 957363d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

.github/workflows/pr-preview-release.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
run-id: ${{ github.event.workflow_run.id }}
3838

3939
- name: Create or Update PR Release
40+
id: release
4041
env:
4142
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4243
RELEASE_TAG: "agentapi_${{ steps.pr.outputs.number }}"
@@ -46,6 +47,7 @@ jobs:
4647
if gh release view "$RELEASE_TAG" --repo ${{ github.repository }} &>/dev/null; then
4748
echo "Updating release $RELEASE_TAG"
4849
gh release upload "$RELEASE_TAG" ./out/* --clobber --repo ${{ github.repository }}
50+
echo "should_comment=false" >> "${GITHUB_OUTPUT}"
4951
else
5052
echo "Creating release $RELEASE_TAG"
5153
gh release create "$RELEASE_TAG" ./out/* \
@@ -54,9 +56,11 @@ jobs:
5456
--repo ${{ github.repository }} \
5557
--latest=false \
5658
--prerelease
59+
echo "should_comment=true" >> "${GITHUB_OUTPUT}"
5760
fi
5861
5962
- name: Comment on PR
63+
if: steps.release.outputs.should_comment == 'true'
6064
uses: actions/github-script@v7
6165
with:
6266
script: |
@@ -68,4 +72,4 @@ jobs:
6872
owner: context.repo.owner,
6973
repo: context.repo.repo,
7074
body: `✅ Preview binaries are ready!\n\nTo test with modules: \`\`\`agentapi_version = "agentapi_${prNumber}"\`\`\` or download from: ${repoUrl}/releases/tag/${releaseTag}`
71-
});
75+
});

0 commit comments

Comments
 (0)