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

fix: added log for existing meetings #185

Merged
merged 1 commit into from
Mar 2, 2024
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/issues.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 10 additions & 6 deletions lib/meetings.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion run.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down