Skip to content

Commit

Permalink
ci: deletes old comments when new appimage is uploaded
Browse files Browse the repository at this point in the history
This commit updates the AppImage workflow to delete older comments
that publish the link to the artifacts before adding the new comment
ensuring that there's always one latest comment with the link to the
last successful AppImage build on a PR.

Wrike Ticket: https://www.wrike.com/open.htm?id=1130198233
  • Loading branch information
guptadev21 authored and pallabpain committed Sep 4, 2024
1 parent 7c76d84 commit 501ce5f
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion .github/workflows/upload-appimage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,44 @@ jobs:
if-no-files-found: error
retention-days: 15

- name: Artifact Comment on PR
- name: Install GitHub CLI
run: |
sudo apt-get update
sudo apt-get install gh
- name: Edit the last bot comment
id: edit-comment
if: github.event_name == 'pull_request'
run: |
set -e
gh pr comment $PR_NUMBER --edit-last -b "
**🤖 Pull Request [Artifacts](https://github.com/rapyuta-robotics/rapyuta-io-cli/actions/runs/"$RUN_ID") (#"$RUN_ID") 🎉**
"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RUN_ID: ${{ github.run_id }}
PR_NUMBER: ${{ github.event.number }}
continue-on-error: true


- name: Delete existing bot comments
if: steps.edit-comment.outcome == 'failure'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
run: |
# Get all comments on the PR where the author is the bot
COMMENTS=$(gh api repos/${{ github.repository }}/issues/$PR_NUMBER/comments --jq '.[] | select(.user.login == "github-actions[bot]") | .id')
# Loop through each bot comment and delete it
for COMMENT_ID in $COMMENTS; do
gh api repos/${{ github.repository }}/issues/comments/$COMMENT_ID -X DELETE
done


- name: Artifact Comment on PR
# if: github.event_name == 'pull_request'
if: steps.edit-comment.outcome == 'failure'
run: |
gh pr comment $PR_NUMBER -b "
**🤖 Pull Request [Artifacts](https://github.com/rapyuta-robotics/rapyuta-io-cli/actions/runs/"$RUN_ID") (#"$RUN_ID") 🎉**
Expand Down

0 comments on commit 501ce5f

Please sign in to comment.