File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed
Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -91,14 +91,15 @@ jobs:
9191 keep_files : true
9292 publish_dir : ./titles-generated
9393
94- - name : PR comment with doc preview
95- uses : actions/github-script@v7
96- with :
97- github-token : ${{ secrets.RHDH_BOT_TOKEN }}
98- script : |
99- github.rest.issues.createComment({
100- issue_number: context.issue.number,
101- owner: context.repo.owner,
102- repo: context.repo.repo,
103- body: 'PR Preview: https://redhat-developer.github.io/red-hat-developers-documentation-rhdh/pr-${{ github.event.number }}/'
104- });
94+ - name : PR comment with doc preview, replacing existing comments with a new one each time
95+ shell : bash
96+ run : |
97+ PR_NUM="${{ github.event.number }}"
98+ # for a given PR, check for existing comments from rhdh-bot; select the last one (if more than one)
99+ if [[ $(gh api repos/{owner}/{repo}/issues/${PR_NUM}/comments | jq '.[]|select(.user.login=="rhdh-bot")|.id' | tail -1) ]]; then
100+ # edit that comment:
101+ gh pr comment ${PR_NUM} --edit-last --body "Updated preview: https://redhat-developer.github.io/red-hat-developers-documentation-rhdh/pr-${PR_NUM}/ @ $(date "+%x %X")"
102+ else
103+ # or create a new one:
104+ gh pr comment ${PR_NUM} --body "Preview: https://redhat-developer.github.io/red-hat-developers-documentation-rhdh/pr-${PR_NUM}/"
105+ fi
You can’t perform that action at this time.
0 commit comments