Skip to content

Commit 061c612

Browse files
committed
dedup variables
1 parent 621ab90 commit 061c612

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

.github/workflows/release.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ jobs:
4141
- if: github.event_name == 'pull_request'
4242
env:
4343
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44+
PR_NUMBER: ${{ github.event.number }}
45+
WORKFLOW: ${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts
4446
run: |
45-
id=$(gh api repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts --jq '.artifacts[0].id')
46-
url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts/$id
47-
comment="Try the changes in this PR by [side-loading the built extension]($url). :rocket:"
47+
url=https://github.com/$WORKFLOW/$(gh api repos/$WORKFLOW --jq '.artifacts[0].id')
48+
commented=$(gh pr view $PR_NUMBER --json comments --jq '.comments[].author.login | select(. | contains("github-actions"))')
49+
body="Try the changes in this PR by [side-loading the built extension]($url). :rocket:"
4850
49-
gh pr comment ${{ github.event.pull_request.number }} --body "$comment"
51+
if [ -z "$commented" ]; then
52+
gh pr comment $PR_NUMBER --body "$body"
53+
else
54+
gh pr comment $PR_NUMBER --edit-last --body "$body"
55+
fi
5056
5157
publish:
5258
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)