diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0124725..ae08d8f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -36,7 +36,7 @@ jobs: schedules: 2020-04-02T17:00:00.0Z/P1D issueTitle: 'Test Meeting <%= date.toFormat("yyyy-MM-dd") %>' createWithin: P2D - meetingLabels: testMeeting, test + meetingLabels: test agendaLabel: meeting-agenda-test createNotes: true repos: pkgjs/meet,pkgjs/meet diff --git a/lib/issues.js b/lib/issues.js index dc1c402..753da8a 100644 --- a/lib/issues.js +++ b/lib/issues.js @@ -24,6 +24,7 @@ module.exports.update = async function (client, issue) { } module.exports.getMeetingIssues = async function (client, opts) { + console.log(`Checking for meeting issues ${opts.owner}/${opts.repo}#${opts.meetingLabels}`) const resp = await client.paginate('GET /repos/{owner}/{repo}/issues', { owner: opts.owner, repo: opts.repo, diff --git a/lib/meetings.js b/lib/meetings.js index 82c4e51..3286612 100644 --- a/lib/meetings.js +++ b/lib/meetings.js @@ -12,12 +12,12 @@ module.exports.createNextMeeting = async function (client, opts) { } module.exports.setMeetingIssueBody = async function (client, opts) { - const issue = await getNextIssue(client, opts) + const issue = getNextIssue(opts) issue.body = typeof opts.template === 'function' ? opts.template(issue) : opts.template return issues.update(client, issue) } -async function getNextIssue (client, opts) { +function getNextIssue (opts) { const now = opts.now || DateTime.utc() const date = getNextScheduledMeeting(opts.schedules, now) const title = typeof opts.issueTitle === 'function' ? opts.issueTitle({ date }) : opts.issueTitle @@ -40,7 +40,7 @@ async function getNextIssue (client, opts) { const shouldCreateNextMeetingIssue = module.exports.shouldCreateNextMeetingIssue = async function (client, opts = {}) { const now = opts.now || DateTime.utc() const createWithin = Duration.fromISO(opts.createWithin) - const issue = getNextIssue(client, opts) + const issue = getNextIssue(opts) const { date: next, title: nextIssueTitle } = issue // Further out than the create within limit @@ -51,15 +51,19 @@ const shouldCreateNextMeetingIssue = module.exports.shouldCreateNextMeetingIssue const meetings = await issues.getMeetingIssues(client, { owner: opts.owner, repo: opts.repo, - label: opts.meetingLabels + meetingLabels: opts.meetingLabels }) - const shouldCreate = !meetings.find((i) => { + console.log(`Checking for meeting titled ${nextIssueTitle}`) + const shouldCreate = meetings.find((i) => { + console.log(`Found meeting issue ${i.title}`) return i.title === nextIssueTitle }) - if (!shouldCreate) { + if (shouldCreate) { + console.log(`Found existing meeting issue: #${shouldCreate.number}`) return false } + console.log('No existing meeting issues found') // Load issues for agenda return issue diff --git a/run.js b/run.js index fbbce15..a7d8086 100644 --- a/run.js +++ b/run.js @@ -20,8 +20,8 @@ const conversions = require('./lib/conversions') const createWithin = core.getInput('createWithin') // variables we use for labels - const meetingLabels = core.getInput('meetingLabels') const agendaLabel = core.getInput('agendaLabel') + const meetingLabels = core.getInput('meetingLabels') // variables we use for content const issueTitle = core.getInput('issueTitle')