Skip to content

Commit

Permalink
Merge pull request #5 from mtfoley/add-issue-comment
Browse files Browse the repository at this point in the history
feat: Add issue comment
  • Loading branch information
bdougie committed Jul 12, 2021
2 parents 1735275 + 4331dd0 commit 67f0766
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

## Usage

This GitHub Action pins an issue based on a specified label.
This GitHub Action lets a prospective contributor assign themselves to an issue, and optionally leaves a comment on the issue.


## Setup

This GitHub Action requires a GITHUB_TOKEN and can be optionally configured with a message to the prospective contributor.

```yaml
# .github/workflows/take.yml
name: Assign issue to contributor
Expand All @@ -23,4 +25,6 @@ jobs:
uses: bdougie/take-action@main
env:
GITHUB_TOKEN: ${{ github.token }}
with:
message: Thanks for taking this issue! Let us know if you have any questions!
```
11 changes: 11 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ branding:
icon: 'thumbs-up'
color: 'white'

inputs:
message:
description: 'Message to prospective contributor'
required: false
default: ''

runs:
using: "composite"
Expand All @@ -20,5 +25,11 @@ runs:
echo "Assigning issue $ISSUE_NUMBER to $LOGIN"
echo "Using the link: https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees"
curl -H "Authorization: token $GITHUB_TOKEN" -d '{"assignees":["'"$LOGIN"'"]}' https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/assignees
if [[ ! -z $INPUT_MESSAGE ]]; then
jq -n -r --arg body "$INPUT_MESSAGE" '{body: $body}' > payload.json
curl -X POST -H "Authorization: token $GITHUB_TOKEN" --data @payload.json https://api.github.com/repos/$REPO/issues/$ISSUE_NUMBER/comments
fi
fi
shell: bash
env:
INPUT_MESSAGE: "${{ inputs.message }}"

0 comments on commit 67f0766

Please sign in to comment.