Skip to content

Commit

Permalink
ci: automate research spike issue completion (#8098)
Browse files Browse the repository at this point in the history
**Related Issue:** n/a

## Summary
Adds automation when developers complete research spikes associated with
the `spike` label.

How it works:
1. The developer adds the `spike complete` label
2. The script runs, and:
    - The `spike` label is removed
    - If present, the `1 - assigned` label is removed
    - Adds the `0 - new` and `needs milestone` labels
    - All assignees are removed and the milestone is cleared
- Calcite PMs are notified (currently set to @brittneytewks and myself)
to add to an upcoming milestone
        - Also discoverable via the `needs milestone` label
  • Loading branch information
geospatialem authored Oct 31, 2023
1 parent e980be0 commit 36489f3
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
63 changes: 63 additions & 0 deletions .github/scripts/notifyWhenSpikeComplete.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
// When the "spike complete" label is added to an issue:
// 1. Modifies the labels,
// 2. Updates the assignees and milestone, and
// 3. Generates a notification to the Calcite project manager(s)
//
// The secret is formatted like so: person1, person2, person3
//
// Note the script automatically adds the "@" character in to notify the project manager(s)
module.exports = async ({ github, context }) => {
const { managers } = process.env;
const { label } = context.payload;

if (label && label.name === "spike complete") {
// Add a "@" character to notify the user
const calcite_managers = managers.split(",").map((v) => " @" + v.trim());

const issueProps = {
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
};

/* Modify labels */
try {
await github.rest.issues.removeLabel({
...issueProps,
name: "spike",
});
} catch (err) {
console.log("The 'spike' label is not associated with the issue", err);
}

try {
await github.rest.issues.removeLabel({
...issueProps,
name: "1 - assigned",
});
} catch (err) {
console.log("The '1 - assigned' label is not associated with the issue", err);
}

// Add labels
await github.rest.issues.addLabels({
...issueProps,
labels: ["0 - new", "needs milestone"],
});

/* Update issue */

// Clear assignees and milestone
await github.rest.issues.update({
...issueProps,
assignees: [],
milestone: null,
});

// Add a comment to notify the project manager(s)
await github.rest.issues.createComment({
...issueProps,
body: `cc ${calcite_managers}`,
});
}
};
21 changes: 21 additions & 0 deletions .github/workflows/spike-complete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: "Spike complete"

on:
issues:
types: [labeled]

jobs:
ready-for-dev:
if: github.event.label.name == 'spike complete'
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/github-script@v6
env:
managers: ${{secrets.CALCITE_MANAGERS}}
with:
script: |
const action = require('${{ github.workspace }}/.github/scripts/notifyWhenSpikeComplete.js')
await action({github, context, core})

0 comments on commit 36489f3

Please sign in to comment.