Skip to content

Commit

Permalink
Setup functionality for commenting from a file (#18)
Browse files Browse the repository at this point in the history
* Update package versions and rebuild

* Fix github.GitHub is not a constructor issue

* Get action in a working condition

* Introduce commenting from a file

* Update test workflow file
- includes removing the soon to be deprecated set-outputs
- Put the Test File step into its own job

* README updates + ensure we use node16

* Fix failing outputs job test
  • Loading branch information
JoseThen authored Aug 30, 2023
1 parent e744cf8 commit c5aa01d
Show file tree
Hide file tree
Showing 8 changed files with 6,020 additions and 21,938 deletions.
25 changes: 21 additions & 4 deletions .github/workflows/test-comments.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Test Regular Comment
uses: ./
Expand All @@ -20,17 +20,19 @@ jobs:

test-json:
name: Test Json
permissions:
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: set output
id: set
run: |
echo ::set-output name=theJson::$(cat ./test-assets/test.json)
echo 'theJSON<<EOF' >> $GITHUB_OUTPUT
echo "$(cat ./test-assets/test.json)" >> $GITHUB_OUTPUT
echo 'EOF' >> $GITHUB_OUTPUT
- name: Test JSON Comment 1
uses: ./
Expand All @@ -43,3 +45,18 @@ jobs:
with:
json: '{ "this": "pr", "is": "the", "bees": "knees"}'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

test-file:
name: Test File
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Test File Commment
uses: ./
with:
file_path: './test-assets/test.md'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23 changes: 19 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ This action can be used to post a dynamic comment on a github PR

**Optional** A JSON comment you would like to post. Default `''`.

### 'file_path'

**Optional** Path to a file containing `MarkDown` (preffered) syntax with your comment.

### `GITHUB_TOKEN`

**Required** The value of your GitHub Actions GitHub Token, this is
Expand All @@ -35,24 +39,35 @@ permissions:
## Example usage
```yaml
uses: JoseThen/comment-pr@v1.1.1
uses: JoseThen/comment-pr@v1.2.0
with:
comment: 'This PR is the bees knees!'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
```yaml
uses: JoseThen/comment-pr@v1.1.1
uses: JoseThen/comment-pr@v1.2.0
with:
json: '{ "this": "pr", "is": "the", "bees": "knees"}'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
```yaml
uses: JoseThen/[email protected]
with:
file_path: './tmp/pr-comment.md'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
## Development
You need `vercel/ncc` installed with `npm i -g @vercel/ncc` before you can
- You need `vercel/ncc` installed with `npm i -g @vercel/ncc` before you can
compile the logic.

To build just make sure `npm ci` has been run and use `ncc build index.js`
- To build just make sure `npm ci` has been run and use `ncc build index.js`

- If you don't want to download `nodejs` and `npm` you can keep this containerized on the fly
with `docker run --rm -it -v .:/app node:lts bash` and work from the `/app` dir in the container.

## Contributors ✨

Expand Down
6 changes: 5 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ inputs:
description: 'JSON Code Comment you would like to post'
required: false
default: ''
file_path:
description: 'Path to file containing comment'
required: false
default: ''
GITHUB_TOKEN:
description: 'Github Token for authentication'
required: true
runs:
using: 'node12'
using: 'node16'
main: 'dist/index.js'
Loading

0 comments on commit c5aa01d

Please sign in to comment.