Skip to content

Commit

Permalink
ci: add design complete automation (#7184)
Browse files Browse the repository at this point in the history
**Related Issue:** n/a

## Summary
Adds automation for our design complete process, where when the
`design-complete` label is added the following occurs:
- Remove the `design` and `1 - assigned` labels
- Achieved through two separate `removeLabel` API calls, as there is not
an API call to remove more than one without removing all labels.
- Add the `0 - new` and `needs milestone` labels
- Clear the assignee(s) and milestone
- CC @brittneytewks and I in the issue's body
- Achieved via the `CALCITE_MANAGERS` secret (current value:
`geospatialem, brittneytewks`)

~Leverages the `ADMIN_TOKEN` secret 🔒 for admin access to update the
labels with the proper permissions.~ Updated to our default PAT using
write permissions
  • Loading branch information
geospatialem authored Jun 16, 2023
1 parent 667ee47 commit 91cd4e3
Showing 1 changed file with 76 additions and 0 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/design-complete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# When the "design-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)
name: "Design complete"

on:
issues:
types: [labeled]

jobs:
design-complete:
if: github.event.label.name == 'design-complete'
permissions:
issues: write
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
env:
managers: ${{secrets.CALCITE_MANAGERS}}
with:
script: |
const { managers } = process.env;
const { label } = context.payload;
if (label && label.name === "design-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 */
// Remove "Design" label
await github.rest.issues.removeLabel({
...issueProps,
name: "design"
});
// Remove "1 - assigned" label
await github.rest.issues.removeLabel({
...issueProps,
name: "1 - assigned"
});
// 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}`,
});
}

0 comments on commit 91cd4e3

Please sign in to comment.