diff --git a/.github/actions/oppiabot/src/issues/checkIssueLabels.js b/.github/actions/oppiabot/src/issues/checkIssueLabels.js index b7bb459..d38c83d 100644 --- a/.github/actions/oppiabot/src/issues/checkIssueLabels.js +++ b/.github/actions/oppiabot/src/issues/checkIssueLabels.js @@ -9,13 +9,15 @@ const checkLabels = async () => { const token = core.getInput('repo-token'); const label = context.payload.label; const octokit = new GitHub(token); - const user = context.payload.sender.login + const user = context.payload.sender.login; - if (label.name === GOOD_FIRST_LABEL && - !whitelist.goodFirstIssue.includes(user)) { - core.info(`good first issue label got added by non whitelisted user`); + if ( + label.name === GOOD_FIRST_LABEL && + !whitelist.goodFirstIssue.includes(user) + ) { + core.info(`good first issue label got added by non whitelisted individual`); await handleGoodFirstIssue(octokit, user); - } else if(prLabels.includes(label.name) || label.name.startsWith('PR')) { + } else if (prLabels.includes(label.name) || label.name.startsWith('PR')) { core.info('PR label got added on an issue'); await handlePRLabel(octokit, label.name, user); } @@ -30,24 +32,26 @@ const checkLabels = async () => { const handleGoodFirstIssue = async (octokit, user) => { const issueNumber = context.payload.issue.number; // Comment on the issue and ping the onboarding team lead. - await octokit.issues.createComment( - { - body:'Hi @' + user + ', thanks for proposing this as a good first ' + - 'issue. Looping in @' + whitelist.teamLeads.onboardingTeam + - ' to confirm, removing the label until he does so.', - issue_number: issueNumber, - owner: context.repo.owner, - repo: context.repo.repo, - } - ); + await octokit.issues.createComment({ + body: + 'Hi @' + + user + + ', thanks for proposing this as a good first ' + + 'issue. Looping in @' + + whitelist.teamLeads.onboardingTeam + + ' to confirm, removing the label until he does so.', + issue_number: issueNumber, + owner: context.repo.owner, + repo: context.repo.repo, + }); // Remove the label. core.info(`Removing the label`); await octokit.issues.removeLabel({ - issue_number:issueNumber, + issue_number: issueNumber, name: GOOD_FIRST_LABEL, owner: context.repo.owner, - repo: context.repo.repo - }) + repo: context.repo.repo, + }); }; /** @@ -61,34 +65,39 @@ const handlePRLabel = async (octokit, label, user) => { const issueNumber = context.payload.issue.number; const linkText = 'here'; // add doc link. - const link = linkText.link() - let commentBody = '' - if(label.startsWith('PR CHANGELOG')) { + const link = linkText.link(); + let commentBody = ''; + if (label.startsWith('PR CHANGELOG')) { // Handle case for a changelog label. - commentBody = 'Hi @' + user + ', changelog labels should not be used on issues.' + - ' I’m removing the label. You can learn more about labels ' + link; + commentBody = + 'Hi @' + + user + + ', changelog labels should not be used on issues.' + + ' I’m removing the label. You can learn more about labels ' + + link; } else { - commentBody = 'Hi @' + user + ', the label label should only be used in pull requests.' + - ' I’m removing the label. You can learn more about labels ' + link; + commentBody = + 'Hi @' + + user + + ', the label label should only be used in pull requests.' + + ' I’m removing the label. You can learn more about labels ' + + link; } - await octokit.issues.createComment( - { - body:commentBody, - issue_number: issueNumber, - owner: context.repo.owner, - repo: context.repo.repo, - } - ); + await octokit.issues.createComment({ + body: commentBody, + issue_number: issueNumber, + owner: context.repo.owner, + repo: context.repo.repo, + }); // Remove the label. await octokit.issues.removeLabel({ - issue_number:issueNumber, + issue_number: issueNumber, name: label, owner: context.repo.owner, - repo: context.repo.repo - }) - + repo: context.repo.repo, + }); }; module.exports = { diff --git a/.github/workflows/on-push.yml b/.github/workflows/on-push.yml new file mode 100644 index 0000000..cf8c7ba --- /dev/null +++ b/.github/workflows/on-push.yml @@ -0,0 +1,28 @@ +# This is a basic workflow to help you get started with Actions + +name: WIP TITLE + +# Controls when the action will run. Triggers the workflow on push or pull request +# events but only for the master branch +on: + push: + branches: [master] + pull_request: + types: + - synchronize + - edited + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it + - uses: actions/checkout@v2 + - uses: ./.github/actions/no-wip + with: + repo-token: ${{secrets.GITHUB_TOKEN}} diff --git a/README.md b/README.md index f456238..629f388 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,5 @@ # Simple GitHub Action +Testing This action will not comment on all Pull requests made in this repository. +Modifying the Readme.