From 7c90a39fe995e83d8317a541b192fef14c2db58f Mon Sep 17 00:00:00 2001 From: jdsolanki0001 Date: Tue, 28 Sep 2021 12:28:14 +0530 Subject: [PATCH] feat(action): Updated readme & removed unnecessary logging --- README.md | 102 ++++++++++++++++++++++++++++++++++++++++++++++++-- action.yml | 5 ++- dist/index.js | 6 +-- index.js | 6 +-- 4 files changed, 108 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 23c7f17..2da240c 100644 --- a/README.md +++ b/README.md @@ -2,8 +2,8 @@ This actions toggle labels like "awaiting-reply" or "need-more-info" which indicates response is required for further action. This is useful if you want to filter out issue already responded to the issue author but the author isn't responded back. -**Usecase:** -Mostly in premium product or service customer support is top priority. In this scenario customer may create issue and sales team replies back withing their business days. This action really helps in filtering only those issues which requires sales teams response. Those issue which are already answered/responded will be marked via `awaiting-reply` or `need-more-info`. +**Use case:** +Mostly in premium product or service customer support is top priority. In this scenario customer may create issue and sales team replies back withing their business days. This action really helps in filtering only those issues which requires sales teams response. Those issue which are already answered/responded will be marked via "awaiting-reply" or "need-more-info". This is same of large open source community where an individual what to help people and want to check only those issues where no team member responded yet. @@ -11,9 +11,11 @@ This is same of large open source community where an individual what to help peo ## Inputs -### `token`* +### `token` -GitHub personal token +#### *Default: ${{ github.token }}* + +GitHub token ### `label`* @@ -47,6 +49,98 @@ Ignore operation if commented by team members specified in `exclude-members`. Th ## Example Usage +> NOTE: Do update action version `jd-0001/gh-action-toggle-awaiting-reply-label@{YOUR_DESIRED_VERSION}`. This will help you keep using this action if we introduce breaking changes. + +### Toggle specified label on each issue + +```yml +on: + issue_comment: + types: [created] + +jobs: + hello_world_job: + runs-on: ubuntu-latest + name: Job for toggling label + steps: + - name: Toggle label + uses: jd-0001/gh-action-toggle-awaiting-reply-label@1.0.0 + with: + label: question +``` + +### Remove specified label only if repo owner or member comment on issue (not collaborator) + +```yml +on: + issue_comment: + types: [created] + +jobs: + hello_world_job: + runs-on: ubuntu-latest + name: Job for toggling label + steps: + - name: Toggle label + uses: jd-0001/gh-action-toggle-awaiting-reply-label@1.0.0 + with: + label: question + member-association: OWNER, MEMBER +``` + +### Ignore toggling label if specified label is present on issue + ```yml +on: + issue_comment: + types: [created] + +jobs: + hello_world_job: + runs-on: ubuntu-latest + name: Job for toggling label + steps: + - name: Toggle label + uses: jd-0001/gh-action-toggle-awaiting-reply-label@1.0.0 + with: + label: question + ignore-label: internal +``` +### Only toggle label if specified label is present on issue + +```yml +on: + issue_comment: + types: [created] + +jobs: + hello_world_job: + runs-on: ubuntu-latest + name: Job for toggling label + steps: + - name: Toggle label + uses: jd-0001/gh-action-toggle-awaiting-reply-label@1.0.0 + with: + label: question + only-if-label: support +``` + +### Ignore removing label if mentioned users comment on issue and still present in `member-association` + +```yml +on: + issue_comment: + types: [created] + +jobs: + hello_world_job: + runs-on: ubuntu-latest + name: Job for toggling label + steps: + - name: Toggle label + uses: jd-0001/gh-action-toggle-awaiting-reply-label@1.0.0 + with: + label: question + exclude-members: jd-0001, johnDoe123 ``` diff --git a/action.yml b/action.yml index 7734675..ba8eb7f 100644 --- a/action.yml +++ b/action.yml @@ -1,9 +1,12 @@ name: 'Toggle awaiting-reply label of issue' description: 'Toggle awaiting-reply or any label when issue author or team member comment on issue.' author: jd-0001 +branding: + icon: award + color: purple inputs: token: - description: "GitHub personal token" + description: "GitHub token" required: false default: ${{ github.token }} label: diff --git a/dist/index.js b/dist/index.js index fc9b07c..e6c719d 100644 --- a/dist/index.js +++ b/dist/index.js @@ -8384,8 +8384,8 @@ const hasLabel = (issue, label) => { const octokit = getOctokit() const ctx = github.context - console.log(`ctx.eventName: ${ctx.eventName}`) - console.log(`Payload: ${JSON.stringify(ctx.payload, undefined, 2)}`) + // console.log(`ctx.eventName: ${ctx.eventName}`) + // console.log(`Payload: ${JSON.stringify(ctx.payload, undefined, 2)}`) // Docs: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows @@ -8411,7 +8411,7 @@ const hasLabel = (issue, label) => { repo: ctx.repo.repo, }) - console.log("Issue:", JSON.stringify(issue, undefined, 2)) + // console.log("Issue:", JSON.stringify(issue, undefined, 2)) // If issue is closed => return if (issue.state === "closed") return diff --git a/index.js b/index.js index c133791..30b5ff4 100644 --- a/index.js +++ b/index.js @@ -46,8 +46,8 @@ const hasLabel = (issue, label) => { const octokit = getOctokit() const ctx = github.context - console.log(`ctx.eventName: ${ctx.eventName}`) - console.log(`Payload: ${JSON.stringify(ctx.payload, undefined, 2)}`) + // console.log(`ctx.eventName: ${ctx.eventName}`) + // console.log(`Payload: ${JSON.stringify(ctx.payload, undefined, 2)}`) // Docs: https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows @@ -73,7 +73,7 @@ const hasLabel = (issue, label) => { repo: ctx.repo.repo, }) - console.log("Issue:", JSON.stringify(issue, undefined, 2)) + // console.log("Issue:", JSON.stringify(issue, undefined, 2)) // If issue is closed => return if (issue.state === "closed") return