Skip to content

Added logs on slack ocwm notification workflows for debugging #937

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

Open
wants to merge 1 commit into
base: main
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
34 changes: 32 additions & 2 deletions .github/workflows/ocwm-creator.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -94,36 +99,61 @@ 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 }`, {
});

console.log("OCWM Issue:" + JSON.stringify(ocwmissue));

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 = `{
"issue": "https://github.com/${context.repo.owner}/${context.repo.repo}/issues/${ocwmnumber}",
"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);
}
41 changes: 39 additions & 2 deletions .github/workflows/ocwm-reminders.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,26 +67,63 @@ 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 = `{
"issue": "https://github.com/${process.env.OWNER}/${process.env.REPO}/issues/${issueNumber}",
"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);
}