Skip to content

Commit

Permalink
readme: update latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
scriptnull committed Jul 21, 2023
1 parent 1055836 commit 146c635
Showing 1 changed file with 41 additions and 43 deletions.
84 changes: 41 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@

GitHub Action to notify progress by commenting on GitHub issues, pull requests, and commits.

Commenting inspired by GitHub bots like [netlify](https://github.com/apps/netlify), [sonarcloud](https://github.com/apps/sonarcloud) etc.
Commenting inspired by GitHub bots like [netlify](https://github.com/apps/netlify), [sonarcloud](https://github.com/apps/sonarcloud) etc.

Used at [Hasura](https://hasura.io/) to relay progress of long running GitHub Action workflows on pull requests.

## Use case

When deploying preview for a pull request, the GitHub workflow starts by commenting
When deploying preview for a pull request, the GitHub workflow starts by commenting

![review-app-start](images/review-app-start.png)

Expand All @@ -23,18 +23,19 @@ If the workflow succeeds, the bot comments the details of the preview environmen
![review-app-end](images/review-app-end.png)

## Usage

```yml
- uses: hasura/comment-progress@v2.2.0
- uses: hasura/comment-progress@v2.3.0
with:
# The GitHub token to be used when creating/updating comments
# ${{ secrets.GITHUB_TOKEN }} is provided by default by GitHub actions
github-token: ${{ secrets.GITHUB_TOKEN }}

# The repository to which the pull request or issue belongs to
# ${{ github.repository }} gives the slug of the repository on which the action is running
repository: 'my-org/my-repo'
repository: "my-org/my-repo"

# The pull request or issue number on which the comment should be made
# The pull request or issue number on which the comment should be made
number: ${{ github.event.number }}

# The commit sha on which the comment should be made
Expand All @@ -45,7 +46,7 @@ If the workflow succeeds, the bot comments the details of the preview environmen
id: deploy-progress

# Markdown message to be used for commenting
message: 'Thank you for opening this PR :pray:'
message: "Thank you for opening this PR :pray:"

# Comments on the PR/issue and fails the job
fail: true
Expand All @@ -62,12 +63,12 @@ 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.

## Scenarios

- [Make a simple comment on an issue or pull request](#make-a-simple-comment-on-an-issue-or-pull-request)
- [Make a simple comment on a commit](#make-a-simple-comment-on-a-commit)
- [Make a comment and append updates to the same comment](#make-a-comment-and-append-updates-to-the-same-comment)
Expand All @@ -82,25 +83,26 @@ Making a simple thank you comment via the github-actions user whenever a pull re
on:
pull_request:
types: [opened]

jobs:
thank-user:
runs-on: ubuntu-20.04
name: Say thanks for the PR
steps:
- name: comment on the pull request
uses: hasura/comment-progress@v2.2.0
uses: hasura/comment-progress@v2.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: 'my-org/my-repo'
repository: "my-org/my-repo"
number: ${{ github.event.number }}
id: thank-you-comment
message: 'Thank you for opening this PR :pray:'
message: "Thank you for opening this PR :pray:"
```

![say-thanks](images/normal-mode.png)

### Make a simple comment on a commit

This is very similar to commenting on an issue/PR. Here, instead of providing the `number` field we provide the `commit-sha` which is the SHA of the commit that we want to comment on.

```yml
Expand All @@ -115,14 +117,13 @@ jobs:
name: Comment on commit with some info
steps:
- name: Comment on commit
uses: hasura/comment-progress@v2.2.0
uses: hasura/comment-progress@v2.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: 'my-org/my-repo'
repository: "my-org/my-repo"
commit-sha: ${{ github.sha }}
id: commit-comment
message: 'This is a commit comment :D.'

message: "This is a commit comment :D."
```

### Make a comment and append updates to the same comment
Expand All @@ -133,35 +134,35 @@ This makes use of the `append` flag to add the message to the end of an already
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.2.0
- name: Notify about starting this deployment
uses: hasura/comment-progress@v2.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: 'my-org/my-repo'
repository: "my-org/my-repo"
number: ${{ github.event.number }}
id: deploy-preview
message: 'Starting deployment of this pull request.'
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.2.0
- 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'
repository: "my-org/my-repo"
number: ${{ github.event.number }}
id: deploy-preview
message: 'Deployment of a preview for this pull request was successful.'
append: true
message: "Deployment of a preview for this pull request was successful."
append: true
```

### Delete older/stale comment and add a new comment
Expand All @@ -173,37 +174,37 @@ on:
workflow_dispatch:
inputs:
number:
description: 'pull request number'
description: "pull request number"
required: true

jobs:
deploy-preview:
runs-on: ubuntu-20.04
name: Deploy preview
steps:
- name: Notify about starting this deployment
uses: hasura/comment-progress@v2.2.0
- name: Notify about starting this deployment
uses: hasura/comment-progress@v2.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: 'my-org/my-repo'
repository: "my-org/my-repo"
number: ${{ github.event.inputs.number }}
id: deploy-preview
message: 'Starting deployment of this pull request.'
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.2.0
- 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'
repository: "my-org/my-repo"
number: ${{ github.event.inputs.number }}
id: deploy-preview
message: 'Deployment of a preview for this pull request was successful.'
recreate: true
message: "Deployment of a preview for this pull request was successful."
recreate: true
```

## Delete a comment which is no longer relevant
Expand All @@ -214,17 +215,17 @@ Take a case where you need to delete a comment which is no longer relevant. E.g.
on:
pull_request:
types: [closed]

jobs:
cleanup-automated-comments:
runs-on: ubuntu-20.04
name: Delete automated PR comments
steps:
- name: delete comment that contains a preview link
uses: hasura/comment-progress@v2.2.0
uses: hasura/comment-progress@v2.3.0
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: 'my-org/my-repo'
repository: "my-org/my-repo"
number: ${{ github.event.number }}
id: preview-url
```
Expand All @@ -239,9 +240,6 @@ After making changes to the source code, you will need to perform a packaging st
npm install
npm run build

git add .
git add .
git commit -m "generates dist for updated code"
```



0 comments on commit 146c635

Please sign in to comment.