Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
hramos committed Mar 17, 2020
0 parents commit 4d47f33
Show file tree
Hide file tree
Showing 527 changed files with 186,592 additions and 0 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Héctor Ramos.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
58 changes: 58 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Label Issues that Need Attention When Author Responds

Applies a label whenever the original author of an issue adds a comment to an issue that needed their response.

## How It Works

If the original author of an issue adds a comment on their issue, and that issue has a 'Needs Author Feedback' label, this action will remove the label and apply a 'Needs Attention' label.

## Inputs

### `response-required-label`

The name of the label that indicates an issue that needs a response from the author. Default `"Needs Author Feedback"`.

### `needs-attention-label`

The name of the label that indicates an issue that needs attention. Default `"Needs Attention"`.

### `repo-token`

**Required.** The `GITHUB_TOKEN` for the repository being acted on.

## Outputs

### `results`

A string description of any actions taken.

## Example usage

```
name: Issue Needs Attention
# This workflow is triggered on issue comments.
on:
issue_comment:
types: created
jobs:
applyNeedsAttentionLabel:
name: Apply Needs Attention Label
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Needs Attention Label
uses: hramos/needs-attention@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
```

Configuring labels:

```
uses: hramos/needs-attention@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
response-required-label: 'Needs Author Feedback'
needs-attention-label: 'Needs Attention'
```
21 changes: 21 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: 'Needs Attention'
description: 'Applies a label whenever the original author of an issue adds a comment to an issue that needed their response.'
inputs:
response-required-label:
description: 'The name of the label that indicates an issue that needs a response from the author.'
default: 'Needs Author Feedback'
needs-attention-label:
description: 'The name of the label that indicates an issue that needs attention.'
default: 'Needs Attention'
perform:
description: 'Whether to perform any action, if needed. Set to false to do a dry-run.'
default: true
repo-token:
description: 'The GITHUB_TOKEN for the repository being acted on.'
required: true
outputs:
result:
description: 'A string description of any actions taken.'
runs:
using: 'node12'
main: 'index.js'
39 changes: 39 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const core = require('@actions/core');
const github = require('@actions/github');

const myToken = core.getInput('repo-token');
const octokit = new github.GitHub(myToken);

async function run() {
try {
const {owner, repo} = github.context.repo;
const issue = github.context.payload.issue;
const labels = issue.labels;
const issue_number = issue.number;
const comment = github.context.payload.comment;

const responseRequiredLabel = core.getInput('response-required-label');
const needsAttentionLabel = core.getInput('needs-attention-label');
const perform = core.getInput('perform');

const isMarked = labels.map(label => label.name).includes(responseRequiredLabel)

if (isMarked && issue.user.login === comment.user.login) {
if (perform) {
console.log(`${owner}/${repo}#${issue_number} needs attention`);
await octokit.issues.removeLabel({owner, repo, issue_number, name: responseRequiredLabel})
await octokit.issues.addLabels({owner, repo, issue_number, labels: [needsAttentionLabel]})
core.setOutput("result", `${owner}/${repo}#${issue_number} marked as needing attention`);
} else {
console.log(`${owner}/${repo}#${issue_number} would have been flagged as needing attention (dry-run)`);
core.setOutput("result", `dry-run`);
}
} else {
core.setOutput("result", `${owner}/${repo}#${issue_number} does not need attention`);
}
} catch (error) {
core.setFailed(error.message);
}
}

run();
1 change: 1 addition & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

146 changes: 146 additions & 0 deletions node_modules/@actions/core/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions node_modules/@actions/core/lib/command.d.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

78 changes: 78 additions & 0 deletions node_modules/@actions/core/lib/command.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/@actions/core/lib/command.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4d47f33

Please sign in to comment.