deskflow/.github/workflows/issue-check-support.yml
Nick Bolton c2dd232564
Move issue check logic to GitHub script (#7486)
* Fixed new line strip regex

* Move issue check logic to GitHub script

* Fixed variable name issueBody
2024-09-06 14:49:13 +01:00

63 lines
2.2 KiB
YAML

name: Check if tech support issue
on:
issues:
types: [opened]
workflow_dispatch:
inputs:
issue_number:
description: "Issue number"
required: true
issue_body:
description: "Issue body"
required: true
jobs:
issue-check-support:
runs-on: ubuntu-latest
env:
ISSUE_BODY: ${{ github.event.issue.body || github.event.inputs.issue_body }}
ISSUE_NUMBER: ${{ github.event.issue.number || github.event.inputs.issue_number }}
steps:
- name: Add comment for customer
env:
CUSTOMER_PATTERN: What type of Synergy user are you\?\s*Customer
NO_TICKET_PATTERN: Support ticket number \(for customers\)\s*_No response_
COMMENT_BODY: |
Hello! :wave: As a customer, you're entitled to tech support which is included in your
license at no extra cost.
Please [raise a support ticket](https://symless.com/synergy/contact) if you'd like to
take advantage of that.
If that works for you, then please let us know your ticket number so we can continue
the discussion there. Thanks!
uses: actions/github-script@v6
with:
script: |
const issueNumber = process.env.ISSUE_NUMBER;
const issueBody = process.env.ISSUE_BODY;
const customerPattern = new RegExp(process.env.CUSTOMER_PATTERN);
const noTicketPattern = new RegExp(process.env.NO_TICKET_PATTERN);
const isCustomer = customerPattern.test(issueBody);
const noTicket = noTicketPattern.test(issueBody);
if (!isCustomer) {
console.log('Not a customer');
return;
}
if (!noTicket) {
console.log('Already has a ticket');
return;
}
// Strip newlines, since GitHub comments are not markdown.
const commentBody = process.env.COMMENT_BODY.replace(/\n/g, ' ');
console.log('Adding comment to issue:', issueNumber);
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
body: commentBody
});