Skip to content

Deprecate getConquestTally, replace forever vars with expiring charvars #1356

Deprecate getConquestTally, replace forever vars with expiring charvars

Deprecate getConquestTally, replace forever vars with expiring charvars #1356

Workflow file for this run

name: "github"
on:
pull_request_target:
types: [opened]
issues:
types: [opened]
jobs:
Check_Checkboxes:
runs-on: ubuntu-latest
permissions: write-all
steps:
- uses: actions/github-script@v6
with:
script: |
function count_instances(string, word)
{
return string.split(word).length - 1;
}
const event_type = "${{ github.event_name }}"
var checkbox_total = 3
var body_text = ""
var type_name = ""
if (event_type === "pull_request_target")
{
body_text = context.payload.pull_request.body
type_name = "PR"
checkbox_total = 4
}
else // issue
{
body_text = context.payload.issue.body
type_name = "report"
}
// Remove block comments
body_text = body_text.replaceAll(/<!--.*-->/g, "")
console.log(`github.event_name: ${event_type}`)
console.log(`body_text: ${body_text}`)
console.log(`type_name: ${type_name}`)
// Count the filled in checkboxes, comparing checkbox_count to checkbox_total
const checkbox_count = count_instances(body_text, "[x]")
if (checkbox_count < checkbox_total)
{
console.log(`Found ${checkbox_count} completed checkboxes. Leaving a reminder comment.`)
const result = await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `✨ Thanks for the ${type_name}! ✨\n\nThis is a friendly automated reminder that the maintainers won't look at your ${type_name} until you've properly completed all of the checkboxes in the pre-filled template.`
})
}
else
{
console.log(`Found ${checkbox_count} completed checkboxes. All is well.`)
}