From 91cd4e3da224a6b4160169f00eedf4ec99a1e61c Mon Sep 17 00:00:00 2001 From: Kitty Hurley Date: Fri, 16 Jun 2023 10:02:27 -0500 Subject: [PATCH] ci: add design complete automation (#7184) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit **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 --- .github/workflows/design-complete.yml | 76 +++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 .github/workflows/design-complete.yml diff --git a/.github/workflows/design-complete.yml b/.github/workflows/design-complete.yml new file mode 100644 index 00000000000..2afe530a666 --- /dev/null +++ b/.github/workflows/design-complete.yml @@ -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}`, + }); + + }