Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ If the workflow succeeds, the bot comments the details of the preview environmen
# If a comment with the given id is not found, a new comment is created
append: true

# Replaces the message of a comment that already exits with the given id.
# If a comment with the given id is not found, a new comment is created
replace: true

# Deletes all the existing comments matching the given id and
# creates a new comment with the given message
recreate: true
Expand All @@ -63,9 +67,7 @@ If the workflow succeeds, the bot comments the details of the preview environmen
delete: true
```

**Note:** The `number` and `commit-sha` fields are mutually exclusive. Only one of them should be set in a job. If both or none are present, an error will be thrown and the job will fail.

**Note**: The `append` and `recreate` fields are also mutually exclusive. If none of them are set, the job will continue in normal mode but if both are present an error will be thrown and the job will fail.
**Note**: `append`, `recreate`, `replace`, and `delete` fields are mutually exclusive. If more than one of them are set, an error will be thrown and the job will fail.

## Scenarios

Expand Down Expand Up @@ -165,6 +167,45 @@ jobs:
append: true
```

### Create a comment and replace an identical comment

This uses the `replace` flag to replace any existing comment created with the same id.

```yml
on:
pull_request:
types: [opened]

jobs:
deploy-preview:
runs-on: ubuntu-20.04
name: Deploy preview
steps:
- name: Notify about starting this deployment
uses: hasura/comment-progress@v2.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: "my-org/my-repo"
number: ${{ github.event.number }}
id: deploy-preview
message: "Starting deployment of this pull request."

- name: Deploy preview
run: |
echo "deploy preview"
# long running step

- name: Notify about the result of this deployment
uses: hasura/comment-progress@v2.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: "my-org/my-repo"
number: ${{ github.event.number }}
id: deploy-preview
message: "Deployment of a preview for this pull request was successful."
replace: true
```

### Delete older/stale comment and add a new comment

Take a case where you need to re-deploy a preview for your pull request and report the status of the redeployment as a new comment and at the same time delete the old comment containing stale information. `recreate` flag will help in achieving this scenario.
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ inputs:
description: 'If true, message will be appended to existing comment'
required: false
default: false
replace:
description: 'If true, message will replace existing comment'
required: false
default: false
recreate:
description: 'If true, message will be commented after deleting existing comment'
required: false
Expand Down
Loading