Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A Sample WIP PR #41

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
83 changes: 46 additions & 37 deletions .github/actions/oppiabot/src/issues/checkIssueLabels.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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,
});
};

/**
Expand All @@ -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 = {
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/on-push.yml
Original file line number Diff line number Diff line change
@@ -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}}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Simple GitHub Action

Testing
This action will not comment on all Pull requests made in this repository.
Modifying the Readme.