mirror of
https://github.com/fleetdm/fleet
synced 2026-05-23 08:58:41 +00:00
Automate ritual as yml (#13057)
Co-authored-by: Mike McNeil <mikermcneil@users.noreply.github.com>
This commit is contained in:
parent
e9fff6a48e
commit
8234d2e0fe
2 changed files with 115 additions and 15 deletions
|
|
@ -1,53 +1,61 @@
|
|||
- task: "Prioritize for next sprint"
|
||||
-
|
||||
task: "Prioritize for next sprint"
|
||||
startedOn: "2023-08-09"
|
||||
frequency: "Triweekly"
|
||||
description: "Drag next sprint's priorities to the top of the 'Not yet' column." # example of a longer thing: description: "[Prioritizing next sprint](https://fleetdm.com/handbook/company/communication)"
|
||||
dri: "sampfluger88"
|
||||
autoIssue:
|
||||
labels: "#g-ceo"
|
||||
- task: "Process the CEO's inbox"
|
||||
labels: [ "#g-ceo" ]
|
||||
-
|
||||
task: "Process the CEO's inbox"
|
||||
startedOn: "2023-07-29"
|
||||
frequency: "Daily, 4 times"
|
||||
description: "TODO"
|
||||
dri: "sampfluger88"
|
||||
- task: "Process the CEO's calendar"
|
||||
-
|
||||
task: "Process the CEO's calendar"
|
||||
startedOn: "2023-07-29"
|
||||
frequency: "Daily, 4 times"
|
||||
description: "TODO"
|
||||
dri: "sampfluger88"
|
||||
- task: "Fleet IT warehouse management"
|
||||
-
|
||||
task: "Fleet IT warehouse management"
|
||||
startedOn: "2023-07-29"
|
||||
frequency: "Weekly"
|
||||
description: "TODO"
|
||||
dri: "sampfluger88"
|
||||
- task: "Send weekly update"
|
||||
-
|
||||
task: "Send weekly update"
|
||||
startedOn: "2023-07-28"
|
||||
frequency: "Weekly"
|
||||
description: "TODO"
|
||||
dri: "sampfluger88"
|
||||
- task: "Wipe e-group agenda"
|
||||
-
|
||||
task: "Wipe e-group agenda"
|
||||
startedOn: "2023-07-26"
|
||||
frequency: "After each weekly e-group meeting"
|
||||
description: "TODO"
|
||||
dri: "sampfluger88"
|
||||
- task: "Share recording of all hands meeting"
|
||||
description: "[Sharing the all hands recording](https://fleetdm.com/handbook/company/ceo#after-the-all-hands)"
|
||||
-
|
||||
task: "Share recording of all hands meeting"
|
||||
startedOn: "2023-07-xx"
|
||||
frequency: "After each monthly all hands meeting"
|
||||
description: "TODO"
|
||||
description: "[Sharing the all hands recording](https://fleetdm.com/handbook/company/ceo#after-the-all-hands)"
|
||||
dri: "sampfluger88"
|
||||
- task: "Prepare all hands deck"
|
||||
description: "[Preparing the all hands deck](https://fleetdm.com/handbook/company/ceo#prep-for-the-all-hands-call)"
|
||||
-
|
||||
task: "Prepare all hands deck"
|
||||
startedOn: "2023-07-xx"
|
||||
frequency: "The night (CT) before each monthly all hands meeting"
|
||||
description: "TODO"
|
||||
description: "[Preparing the all hands deck](https://fleetdm.com/handbook/company/ceo#prep-for-the-all-hands-call)"
|
||||
dri: "sampfluger88"
|
||||
- task: "Prepare board deck"
|
||||
-
|
||||
task: "Prepare board deck"
|
||||
startedOn: "2023-07-29"
|
||||
frequency: "Two nights (CT) before the day of the mock board meeting"
|
||||
description: "TODO"
|
||||
dri: "sampfluger88"
|
||||
- task: "Process CEO GitHub review requests, mentions, and outstanding PRs"
|
||||
-
|
||||
task: "Process CEO GitHub review requests, mentions, and outstanding PRs"
|
||||
startedOn: "2023-07-29"
|
||||
frequency: "Daily"
|
||||
description: "TODO"
|
||||
92
website/scripts/create-issues-for-todays-rituals.js
vendored
Normal file
92
website/scripts/create-issues-for-todays-rituals.js
vendored
Normal file
|
|
@ -0,0 +1,92 @@
|
|||
module.exports = {
|
||||
|
||||
|
||||
friendlyName: 'Create issues for todays rituals',
|
||||
|
||||
|
||||
description: '',
|
||||
|
||||
|
||||
inputs: {
|
||||
dry: { type: 'boolean', defaultsTo: false, description: 'Whether to do a dry run instead.' },
|
||||
},
|
||||
|
||||
|
||||
fn: async function ({ dry }) {
|
||||
|
||||
let path = require('path');
|
||||
let YAML = require('yaml');
|
||||
let topLvlRepoPath = path.resolve(sails.config.appPath, '../');
|
||||
let baseHeaders = {// (for github api)
|
||||
'User-Agent': 'Fleetie pie',
|
||||
'Authorization': `token ${sails.config.custom.githubAccessToken}`
|
||||
};
|
||||
|
||||
let ritualSources = [
|
||||
{ path: 'handbook/company/rituals.yml', },
|
||||
];
|
||||
for (let ritualSource of ritualSources) {
|
||||
|
||||
// Load rituals
|
||||
let pathToRituals = path.resolve(topLvlRepoPath, ritualSource.path);
|
||||
let rituals = [];
|
||||
let ritualsYml = await sails.helpers.fs.read(pathToRituals);
|
||||
try {
|
||||
rituals = YAML.parse(ritualsYml, { prettyErrors: true });
|
||||
} catch (err) {
|
||||
throw new Error(`Could not parse the YAMl for rituals at ${pathToRituals} on line ${err.linePos.start.line}. To resolve, make sure the YAML is valid, and try again: ` + err.stack);
|
||||
}
|
||||
|
||||
|
||||
// Validate rituals
|
||||
for (let ritual of rituals) {
|
||||
|
||||
let KNOWN_AUTOMATABLE_FREQUENCIES = ['Daily', 'Weekly', 'Triweekly'];//TODO: others
|
||||
if (ritual.autoIssue && !KNOWN_AUTOMATABLE_FREQUENCIES.includes(ritual.frequency)) {
|
||||
throw new Error(`Invalid ritual: "${ritual.task}" indicates frequency "${ritual.frequency}", but that isn't supported with automations turned on. Supported frequencies: ${KNOWN_AUTOMATABLE_FREQUENCIES}`);
|
||||
}
|
||||
|
||||
// TODO: validate task
|
||||
// TODO: validate description
|
||||
// TODO: validate DRI (github username)
|
||||
// TODO: validate ritual.autoIssue
|
||||
// TODO: validate ritual.autoIssue.labels
|
||||
|
||||
// TODO: other validations
|
||||
|
||||
}//∞
|
||||
|
||||
for (let ritual of rituals) {
|
||||
|
||||
if (!ritual.autoIssue) {// « Skip to the next ritual if automations aren't enabled.
|
||||
continue;
|
||||
}
|
||||
|
||||
// Skip to the next ritual if it isn't time yet.
|
||||
if (false) {// TODO
|
||||
continue;
|
||||
}
|
||||
|
||||
// Create an issue with right labels and assignee, in the right repo.
|
||||
if (!dry) {
|
||||
let owner = 'fleetdm';
|
||||
let repo = 'fleet';// TODO: support confidential and classified also
|
||||
// [?] https://docs.github.com/en/rest/issues/issues#create-an-issue
|
||||
await sails.helpers.http.post(`https://api.github.com/repos/${owner}/${repo}/issues`, {
|
||||
title: ritual.task,
|
||||
body: ritual.description,
|
||||
labels: ritual.autoIssue.labels,
|
||||
assignees: [ ritual.dri ]
|
||||
}, baseHeaders);
|
||||
} else {
|
||||
sails.log('Dry run: Would have created an issue for ritual:', ritual);
|
||||
}
|
||||
|
||||
}//∞
|
||||
}//∞
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
Loading…
Reference in a new issue