Skip to content

Application Security Checklist #12

Application Security Checklist

Application Security Checklist #12

Workflow file for this run

name: Foundation Workflow
on:
issues:
types: [opened, edited]
jobs:
labeler:
runs-on: ubuntu-latest
steps:
- name: Label issues based on title
uses: actions/github-script@v6
with:
script: |
// Convert issue title to lowercase to ignore case differences
const issueTitle = context.payload.issue.title.toLowerCase();
const issueNumber = context.payload.issue.number;
const labelsToAdd = [];
// Define labeling rules (all checks are case insensitive now)
if (issueTitle.includes('best practice')) {
labelsToAdd.push('BEST PRACTICE');
}
if (issueTitle.includes('checklist')) {
labelsToAdd.push('CHECKLIST');
}
if (issueTitle.includes('diagram')) {
labelsToAdd.push('DIAGRAM');
}
if (issueTitle.includes('guideline')) {
labelsToAdd.push('GUIDELINE');
}
if (issueTitle.includes('policy')) {
labelsToAdd.push('POLICY');
}
if (issueTitle.includes('procedure')) {
labelsToAdd.push('PROCEDURE');
}
if (issueTitle.includes('standard')) {
labelsToAdd.push('STANDARD');
}
// Add labels to the issue if any matching keywords are found
if (labelsToAdd.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: labelsToAdd
});
}
// Add labels to the issue if any matching keywords are found
if (labelsToAdd.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
labels: labelsToAdd
});
}
// Automatically assign the issue to the user who triggered the event
const username = context.actor; // Get the username of the actor who triggered the event
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
assignees: [username] // Assign issue to the user who opened or edited it
});