diff --git a/index.js b/index.js index ccce3d1..23e6318 100644 --- a/index.js +++ b/index.js @@ -5,30 +5,19 @@ module.exports = (robot) => { robot.on('push', async context => { const config = await context.config('config.yml') const id = config.watchedProject.id - const columns = await context.projects.getProjectColumns({id}) - - const data = { - owner: context.payload.repository.owner.login, - repo: context.payload.repository.name - } + const columns = await context.projects.getProjectColumns({context.repo(id)}) // generate labels based on project column names columns.forEach(async column => { // check if label already exists - const label = await context.issues.getLabel({ - owner: data.owner, - repo: data.repo, - name: column.name - }) + const label = await context.issues.getLabel({context.issue(name: column.name)}) // if it doesn't exist, create a new label if (label.status === 404) { - const newLabel = context.issues.createLabel({ - owner: data.owner, - repo: data.repo, + const newLabel = context.issues.createLabel({context.issue( name: column.name, color: randomColor() - }) + )}) } })