diff --git a/README.md b/README.md index 6e51a55..752104a 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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! ``` diff --git a/action.yml b/action.yml index 3b35f8c..bb3fbeb 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,11 @@ branding: icon: 'thumbs-up' color: 'white' +inputs: + message: + description: 'Message to prospective contributor' + required: false + default: '' runs: using: "composite" @@ -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 }}"