diff --git a/.github/workflows/ocwm-creator.yml b/.github/workflows/ocwm-creator.yml index 64a4c53d..ae66eda2 100644 --- a/.github/workflows/ocwm-creator.yml +++ b/.github/workflows/ocwm-creator.yml @@ -33,14 +33,19 @@ jobs: - name: Generate Issue Title id: create-title run: | + echo "Starting Issue Title Generation..." + # Get the first day of the next month next_month=$(date -u -d "$(date +%Y-%m-01) +1 month" +%Y-%m-01) + echo "Next month first day: $next_month" # Find the first Monday of the next month first_monday=$(date -u -d "$next_month +$(( (8 - $(date -u -d "$next_month" +%u)) % 7 )) days" +%Y-%m-%d) + echo "First Monday of next month: $first_monday" # Calculate the third Monday by adding 14 days to the first Monday third_monday=$(date -u -d "$first_monday +14 days" +%Y-%m-%d) + echo "Third Monday of next month: $third_monday" # Output the issue title with the third Monday's date echo "title=Open Community Working Meeting ${third_monday} - 13:00 PT" >> "$GITHUB_OUTPUT" @@ -94,9 +99,13 @@ jobs: auth: process.env.MY_TOKEN }); - console.log("Token:" + process.env.MY_TOKEN); + console.log("Token available:", process.env.MY_TOKEN ? "Yes (masked)" : "No"); + console.log("Slack webhook available:", process.env.SLACK_WEBHOOK ? "Yes (masked)" : "No"); + const ocwmnumber = ${{ steps.create-issue.outputs.issue-number }}; + console.log("Issue number:", ocwmnumber); + console.log("Fetching issue details..."); const { data: ocwmissue } = await mygithub.request(`GET /repos/${context.repo.owner}/${context.repo.repo}/issues/${ ocwmnumber }`, { }); @@ -104,15 +113,20 @@ jobs: const newBody = `## ${ocwmissue.title}\n\n${ocwmissue.body.split('\n').slice(6).join('\n')}`; + console.log("Updating issue body..."); await mygithub.request(`PATCH /repos/${context.repo.owner}/${context.repo.repo}/issues/${ ocwmnumber }`, { body: newBody, milestone: null, state: 'open', }); + console.log("Issue body updated successfully"); const newTitle = ocwmissue.title; const issueDate = newTitle.replace(/Open Community Working Meeting /g, ""); + console.log("Extracted date from title:", issueDate); + console.log("Issue URL for Slack:", ocwmissue.html_url); + // Notify Slack const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK; const SLACK_MESSAGE = `{ @@ -120,10 +134,26 @@ jobs: "date": "${issueDate}" }`; - await fetch(SLACK_WEBHOOK_URL, { + console.log("Slack message payload:", SLACK_MESSAGE); + + console.log("Sending Slack notification..."); + const slackResponse = await fetch(SLACK_WEBHOOK_URL, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: SLACK_MESSAGE, }); + + console.log("Slack response status:", slackResponse.status); + console.log("Slack response status text:", slackResponse.statusText); + + if (!slackResponse.ok) { + const errorText = await slackResponse.text(); + console.error("Slack notification failed:", errorText); + throw new Error(`Slack notification failed: ${slackResponse.status} ${slackResponse.statusText}`); + } else { + const responseText = await slackResponse.text(); + console.log("Slack notification sent successfully"); + console.log("Slack response:", responseText); + } diff --git a/.github/workflows/ocwm-reminders.yml b/.github/workflows/ocwm-reminders.yml index ab760d03..8c9c3b06 100644 --- a/.github/workflows/ocwm-reminders.yml +++ b/.github/workflows/ocwm-reminders.yml @@ -67,15 +67,36 @@ jobs: auth: process.env.MY_TOKEN }); + console.log("Starting Send reminders step"); + console.log("Token available:", process.env.MY_TOKEN ? "Yes (masked)" : "No"); + console.log("Slack webhook available:", process.env.SLACK_WEBHOOK ? "Yes (masked)" : "No"); + console.log("Owner:", process.env.OWNER); + console.log("Repository:", process.env.REPO); + console.log("OCWM Label:", process.env.OCWM_LABEL); + let targetLabel = encodeURIComponent(process.env.OCWM_LABEL); + console.log("Fetching working meetings from GitHub API..."); const { data: workMeetings } = await mygithub.request(`GET /repos/${process.env.OWNER}/${process.env.REPO}/issues?labels=${targetLabel}&per_page=1`, { }) - const issueNumber = workMeetings[0].number + console.log("Number of work meetings found:", workMeetings.length); + + if (workMeetings.length === 0) { + console.error("No working meetings found with label:", process.env.OCWM_LABEL); + throw new Error("No working meetings found"); + } + + const issueNumber = workMeetings[0].number; const newTitle = workMeetings[0].title; + const issueUrl = workMeetings[0].html_url; const issueDate = newTitle.replace(/Open Community Working Meeting /g, ""); + console.log("Found issue number:", issueNumber); + console.log("Issue title:", newTitle); + console.log("Issue URL:", issueUrl); + console.log("Extracted date from title:", issueDate); + // Notify Slack const SLACK_WEBHOOK_URL = process.env.SLACK_WEBHOOK; const SLACK_MESSAGE = `{ @@ -83,10 +104,26 @@ jobs: "date": "${issueDate}" }`; - await fetch(SLACK_WEBHOOK_URL, { + console.log("Slack message payload:", SLACK_MESSAGE; + + console.log("Sending Slack reminder notification..."); + const slackResponse = await fetch(SLACK_WEBHOOK_URL, { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: SLACK_MESSAGE, }); + + console.log("Slack response status:", slackResponse.status); + console.log("Slack response status text:", slackResponse.statusText); + + if (!slackResponse.ok) { + const errorText = await slackResponse.text(); + console.error("Slack reminder notification failed:", errorText); + throw new Error(`Slack reminder notification failed: ${slackResponse.status} ${slackResponse.statusText}`); + } else { + const responseText = await slackResponse.text(); + console.log("Slack reminder notification sent successfully"); + console.log("Slack response:", responseText); + }