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

add workflow for Agenda Verification and Notifications before Monday Meetings #802

Merged
merged 20 commits into from
Sep 24, 2024
Merged
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
83 changes: 83 additions & 0 deletions .github/workflows/ocwm-pre-meeting-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: OCWM Pre-Meeting Check

on:
schedule:
- cron: '50 21 * * 1' # Runs at 21:50 UTC, which is 10 minutes before 14:00 PT every Monday
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- cron: '50 21 * * 1' # Runs at 21:50 UTC, which is 10 minutes before 14:00 PT every Monday
- cron: '50 18 15-21 * 1' # Runs at 11:50 AM PT on the 3rd Monday of the month

I am suggesting this change because we just decided to make the meetings mothly the 3rd monday of the month and 2 hours earlier as 12:00 PT


jobs:
check_agenda:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Set up Node 20
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Get GitHub Token
uses: actions/create-github-app-token@v1
id: get_workflow_token
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}

- name: Install Dependencies
run: npm install @octokit/[email protected]

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Step to check if today is the third Monday
- name: Check if today is the third Monday
id: check-third-monday
run: |
day=$(date +%d)
dow=$(date +%u) # Day of the week (1 = Monday, ..., 7 = Sunday)
# Check if the day is between 15th and 21st, and if it's Monday (1)
if [ "$dow" -ne 1 ]; then
echo "Not a Monday, exiting..."
exit 0
fi
if [ "$day" -ge 15 ] && [ "$day" -le 21 ]; then
echo "This is the third Monday of the month!"
else
echo "Not the third Monday, exiting..."
exit 0
fi

This new step will make sure the process only runs completely the third monday of the month.

- name: Check Latest OCWM Issue
id: check_issue
env:
MY_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
OWNER: ${{ vars.ORGANISATION }}
REPO: 'community'
OCWM_LABEL: ${{ vars.OCWM_LABEL }}
TEMPLATE_PATH: '../ISSUE_TEMPLATE/open_community_working_meeting.md'
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_GEN_NOTIF }}

This is the secret containing the the webhook

run: |
const fs = require('fs');
const octokit = require('@octokit/core').Octokit;
const mygithub = new octokit({
request: { fetch: fetch, },
auth: process.env.MY_TOKEN
});

// Read the template from the markdown file
const templateContent = fs.readFileSync(process.env.TEMPLATE_PATH, 'utf8');

// Fetch the latest issue with OCWM_LABEL
const { data: issues } = await mygithub.request(`GET /repos/${process.env.OWNER}/${process.env.REPO}/issues?labels=${encodeURIComponent(process.env.OCWM_LABEL)}&per_page=1`);

if (issues.length === 0) {
console.log("No open community working meeting issues found.");
return;
}

const latestIssue = issues[0];
const issueBody = latestIssue.body;

// Check if the issue body matches the template
if (issueBody.includes(templateContent)) {
console.log("Template matched, cancelling the meeting.");

// Add a comment to the issue
await mygithub.request(`POST /repos/${process.env.OWNER}/${process.env.REPO}/issues/${latestIssue.number}/comments`, {
body: "The meeting as been cancelled as there is no agenda for today. Thanks"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
body: "The meeting as been cancelled as there is no agenda for today. Thanks"
body: "The meeting has been cancelled as there is no agenda for today. Thanks everyone!"

});

// Send a notification to Slack
const slackPayload = {
text: `The meeting as been cancelled as there is no agenda for today. Thanks`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
text: `The meeting as been cancelled as there is no agenda for today. Thanks`
text: `The meeting has been cancelled as there is no agenda for today. Thanks everyone!`

};

await fetch(process.env.SLACK_WEBHOOK, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(slackPayload)
});

} else {
console.log("Agenda found. Meeting will proceed.");
}