diff --git a/.github/workflows/new-issue-board-routing.yaml b/.github/workflows/new-issue-board-routing.yaml new file mode 100644 index 000000000..afe882779 --- /dev/null +++ b/.github/workflows/new-issue-board-routing.yaml @@ -0,0 +1,174 @@ +--- +on: + issues: + types: [opened] + +name: Issue Comments +jobs: + ie-project: + name: Add issue to the Inbound Escalations project + runs-on: ubuntu-latest + if: "contains(join(github.event.issue.labels.*.name, ' '), 'inbound-escalation')" + steps: + - uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const PROJECT_NAME = "Inbound Escalations"; + const COLUMN = "New"; + const projects = await github.rest.projects.listForRepo({ + owner: context.payload.repository.owner.login, + repo: context.payload.repository.name, + }); + // there should always be exactly one + const proj = projects.data.filter( + (p) => p.name.indexOf(PROJECT_NAME) !== -1 + )[0]; + if (!proj) { + core.setFailed("Could not find a project called " + PROJECT_NAME); + } + core.info("found project " + PROJECT_NAME); + const columns = await github.rest.projects.listColumns({ + project_id: proj.id, + }); + const column = columns.data.filter( + (c) => c.name.indexOf(COLUMN) !== -1 + )[0]; + if (!column) { + core.setFailed("Could not find a column called " + COLUMN); + } + core.info("found column " + COLUMN); + + await github.rest.projects.createCard({ + column_id: column.id, + content_id: context.payload.issue.id, + content_type: "Issue", + }) + npi-project: + name: Add issue to the New Production Installs project + runs-on: ubuntu-latest + if: "contains(join(github.event.issue.labels.*.name, ' '), 'kind::customer')" + steps: + - uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const PROJECT_NAME = "New Production Installs"; + const COLUMN = "Not Ready"; + const projects = await github.rest.projects.listForRepo({ + owner: context.payload.repository.owner.login, + repo: context.payload.repository.name, + }); + // there should always be exactly one + const proj = projects.data.filter( + (p) => p.name.indexOf(PROJECT_NAME) !== -1 + )[0]; + if (!proj) { + core.setFailed("Could not find a project called " + PROJECT_NAME); + } + core.info("found project " + PROJECT_NAME); + const columns = await github.rest.projects.listColumns({ + project_id: proj.id, + }); + const column = columns.data.filter( + (c) => c.name.indexOf(COLUMN) !== -1 + )[0]; + if (!column) { + core.setFailed("Could not find a column called " + COLUMN); + } + core.info("found column " + COLUMN); + + await github.rest.projects.createCard({ + column_id: column.id, + content_id: context.payload.issue.id, + content_type: "Issue", + }) + enhancements-project: + name: Add issue to the Enhancements project + runs-on: ubuntu-latest + if: > + ( + contains(join(github.event.issue.labels.*.name, ' '), 'kind::bug') + || contains(join(github.event.issue.labels.*.name, ' '), 'kind::feature-request') + ) + steps: + - uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const PROJECT_NAME = "Enhancements"; + const trackedLabel = context.payload.issue.labels.filter(label => label.name === "enhancements::tracked"); + const COLUMN = trackedLabel.length ? "Tracked" : "New"; + + const projects = await github.rest.projects.listForRepo({ + owner: context.payload.repository.owner.login, + repo: context.payload.repository.name, + }); + // there should always be exactly one + const proj = projects.data.filter( + (p) => p.name.indexOf(PROJECT_NAME) !== -1 + )[0]; + if (!proj) { + core.setFailed("Could not find a project called " + PROJECT_NAME); + } + core.info("found project " + PROJECT_NAME); + const columns = await github.rest.projects.listColumns({ + project_id: proj.id, + }); + const column = columns.data.filter( + (c) => c.name.indexOf(COLUMN) !== -1 + )[0]; + if (!column) { + core.setFailed("Could not find a column called " + COLUMN); + } + core.info("found column " + COLUMN); + + await github.rest.projects.createCard({ + column_id: column.id, + content_id: context.payload.issue.id, + content_type: "Issue", + }) + packaging-project: + name: Add issue to the Packaging project + runs-on: ubuntu-latest + if: > + ( + contains(join(github.event.issue.labels.*.name, ' '), 'kind::packaging-step') + ) + steps: + - uses: actions/github-script@v6 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + const PROJECT_NAME = "Packaging Steps"; + const trackedLabel = context.payload.issue.labels.filter(label => label.name === "packaging::started"); + const COLUMN = trackedLabel.length ? "In Progress" : "To Do"; + + const projects = await github.rest.projects.listForRepo({ + owner: context.payload.repository.owner.login, + repo: context.payload.repository.name, + }); + // there should always be exactly one + const proj = projects.data.filter( + (p) => p.name.indexOf(PROJECT_NAME) !== -1 + )[0]; + if (!proj) { + core.setFailed("Could not find a project called " + PROJECT_NAME); + } + core.info("found project " + PROJECT_NAME); + const columns = await github.rest.projects.listColumns({ + project_id: proj.id, + }); + const column = columns.data.filter( + (c) => c.name.indexOf(COLUMN) !== -1 + )[0]; + if (!column) { + core.setFailed("Could not find a column called " + COLUMN); + } + core.info("found column " + COLUMN); + + await github.rest.projects.createCard({ + column_id: column.id, + content_id: context.payload.issue.id, + content_type: "Issue", + })