Skip to content

Commit defef76

Browse files
add workflow for Agenda Verification and Notifications before Monday Meetings (#802)
* Add ocwm-pre-meeting-check.yml to workflow * change ocwm-pre-meeting-check.yml comment * fix: update ocwm-pre-meeting-check.yml with suggested changes * update ocwm-pre-meeting-check.yml * update ocwm-pre-meeting-check.yml for test * second update ocwm-pre-meeting-check.yml for test * third update ocwm-pre-meeting-check.yml for test * forth update ocwm-pre-meeting-check.yml for test * Update ocwm-pre-meeting-check.yml * Update ocwm-pre-meeting-check.yml * Update ocwm-pre-meeting-check.yml * Update ocwm-pre-meeting-check.yml * Update ocwm-pre-meeting-check.yml * Update ocwm-pre-meeting-check.yml * Update ocwm-pre-meeting-check.yml * Update ocwm-pre-meeting-check.yml * Update ocwm-pre-meeting-check.yml * Update ocwm-pre-meeting-check.yml * fix: improve ocwm-pre-meeting-check.yml * Update ocwm-pre-meeting-check.yml We are facing issues with this same logic in other workflows. I am just applying the same version we have in other workflows to consistently merge with master branch. --------- Co-authored-by: Benjamin Granados <[email protected]>
1 parent c8e9105 commit defef76

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: OCWM Pre-Meeting Check
2+
3+
on:
4+
schedule:
5+
- cron: '50 21 * * 1' # Runs at 11:50 AM PT on the 3rd Monday of the month
6+
7+
jobs:
8+
check_agenda:
9+
runs-on: ubuntu-latest
10+
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v4
14+
15+
- name: Set up Node 20
16+
uses: actions/setup-node@v4
17+
with:
18+
node-version: '20'
19+
20+
- name: Get GitHub Token
21+
uses: actions/create-github-app-token@v1
22+
id: get_workflow_token
23+
with:
24+
app-id: ${{ vars.APP_ID }}
25+
private-key: ${{ secrets.PRIVATE_KEY }}
26+
27+
- name: Install Dependencies
28+
run: npm install @octokit/[email protected]
29+
30+
# Step to check if today is the third Monday
31+
- name: Check if today is the third Monday
32+
id: check-third-monday
33+
run: |
34+
day=$(date +%d)
35+
dow=$(date +%u) # Day of the week (1 = Monday, ..., 7 = Sunday)
36+
# Check if the day is between 15th and 21st, and if it's Monday (1)
37+
if [ "$dow" -ne 1 ]; then
38+
echo "Not a Monday, exiting..."
39+
echo "::set-output name=is-third-monday::false"
40+
exit 0
41+
fi
42+
if [ "$day" -ge 15 ] && [ "$day" -le 21 ]; then
43+
echo "This is the third Monday of the month!"
44+
echo "::set-output name=is-third-monday::true"
45+
else
46+
echo "Not the third Monday, exiting..."
47+
echo "::set-output name=is-third-monday::false"
48+
exit 0
49+
fi
50+
51+
- name: Check Latest OCWM Issue
52+
id: check_issue
53+
if: steps.check-third-monday.outputs.is-third-monday == 'true'
54+
uses: actions/github-script@v7
55+
env:
56+
MY_TOKEN: ${{ steps.get_workflow_token.outputs.token }}
57+
OWNER: ${{ vars.ORGANISATION }}
58+
REPO: 'community'
59+
OCWM_LABEL: ${{ vars.OCWM_LABEL }}
60+
TEMPLATE_PATH: '.github/ISSUE_TEMPLATE/open_community_working_meeting.md'
61+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_GEN_NOTIF }}
62+
with:
63+
script: |
64+
const fs = require('fs');
65+
const octokit = require('@octokit/core').Octokit;
66+
const mygithub = new octokit({
67+
request: { fetch: fetch, },
68+
auth: process.env.MY_TOKEN
69+
});
70+
71+
// Read the template from the markdown file
72+
const templateContent = fs.readFileSync(process.env.TEMPLATE_PATH, 'utf8');
73+
74+
// Fetch the latest issue with OCWM_LABEL
75+
const { data: issues } = await mygithub.request(`GET /repos/${process.env.OWNER}/${process.env.REPO}/issues?labels=${encodeURIComponent(process.env.OCWM_LABEL)}&per_page=1`);
76+
77+
if (issues.length === 0) {
78+
console.log("No open community working meeting issues found.");
79+
return;
80+
}
81+
82+
const latestIssue = issues[0];
83+
const issueBody = latestIssue.body;
84+
85+
// Check if the issue body matches the template
86+
if (issueBody.includes(templateContent)) {
87+
console.log("Template matched, cancelling the meeting.");
88+
89+
// Add a comment to the issue
90+
await mygithub.request(`POST /repos/${process.env.OWNER}/${process.env.REPO}/issues/${latestIssue.number}/comments`, {
91+
body: "The meeting has been cancelled as there is no agenda for today. Thanks everyone!"
92+
});
93+
94+
// Send a notification to Slack
95+
const slackPayload = {
96+
text: `The meeting has been cancelled as there is no agenda for today. Thanks everyone!`
97+
};
98+
99+
await fetch(process.env.SLACK_WEBHOOK, {
100+
method: 'POST',
101+
headers: { 'Content-Type': 'application/json' },
102+
body: JSON.stringify(slackPayload)
103+
});
104+
105+
} else {
106+
console.log("Agenda found. Meeting will proceed.");
107+
}

0 commit comments

Comments
 (0)