Skip to content

CONFIG: Fix FluentAssertions dependabot ignore to update-types syntax #230

CONFIG: Fix FluentAssertions dependabot ignore to update-types syntax

CONFIG: Fix FluentAssertions dependabot ignore to update-types syntax #230

Workflow file for this run

name: PR Linter
on:
pull_request:
types:
- opened
- edited
- synchronize
- reopened
- closed
branches:
- main
jobs:
label:
name: Label
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
steps:
- name: Apply Label
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: >-
const prefixes = [
'INFRA:',
'MINOR INFRA:',
'MEDIUM INFRA:',
'MAJOR INFRA:',
'PROVISIONS:',
'RELEASES:',
'DATA:',
'MINOR DATA:',
'MEDIUM DATA:',
'MAJOR DATA:',
'BROKERS:',
'MINOR BROKERS:',
'MEDIUM BROKERS:',
'MAJOR BROKERS:',
'FOUNDATIONS:',
'MINOR FOUNDATIONS:',
'MEDIUM FOUNDATIONS:',
'MAJOR FOUNDATIONS:',
'PROCESSINGS:',
'MINOR PROCESSINGS:',
'MEDIUM PROCESSINGS:',
'MAJOR PROCESSINGS:',
'ORCHESTRATIONS:',
'MINOR ORCHESTRATIONS:',
'MEDIUM ORCHESTRATIONS:',
'MAJOR ORCHESTRATIONS:',
'COORDINATIONS:',
'MINOR COORDINATIONS:',
'MEDIUM COORDINATIONS:',
'MAJOR COORDINATIONS:',
'MANAGEMENTS:',
'MINOR MANAGEMENTS:',
'MEDIUM MANAGEMENTS:',
'MAJOR MANAGEMENTS:',
'AGGREGATIONS:',
'MINOR AGGREGATIONS:',
'MEDIUM AGGREGATIONS:',
'MAJOR AGGREGATIONS:',
'CONTROLLERS:',
'MINOR CONTROLLERS:',
'MEDIUM CONTROLLERS:',
'MAJOR CONTROLLERS:',
'CLIENTS:',
'MINOR CLIENTS:',
'MEDIUM CLIENTS:',
'MAJOR CLIENTS:',
'EXPOSERS:',
'MINOR EXPOSERS:',
'MEDIUM EXPOSERS:',
'MAJOR EXPOSERS:',
'PROVIDERS:',
'BASE:',
'MINOR BASE:',
'MEDIUM BASE:',
'MAJOR BASE:',
'COMPONENTS:',
'MINOR COMPONENTS:',
'MEDIUM COMPONENTS:',
'MAJOR COMPONENTS:',
'VIEWS:',
'MINOR VIEWS:',
'MEDIUM VIEWS:',
'MAJOR VIEWS:',
'PAGES:',
'MINOR PAGES:',
'MEDIUM PAGES:',
'MAJOR PAGES:',
'ACCEPTANCE:',
'MINOR ACCEPTANCE:',
'MEDIUM ACCEPTANCE:',
'MAJOR ACCEPTANCE:',
'INTEGRATIONS:',
'MINOR INTEGRATIONS:',
'MEDIUM INTEGRATIONS:',
'MAJOR INTEGRATIONS:',
'CODE RUB:',
'MINOR CODE RUB:',
'MEDIUM CODE RUB:',
'MAJOR CODE RUB:',
'MINOR FIX:',
'MEDIUM FIX:',
'MAJOR FIX:',
'DOCUMENTATION:',
'CONFIG:',
'STANDARD:',
'DESIGN:',
'MINOR DESIGN:',
'MEDIUM DESIGN:',
'MAJOR DESIGN:',
'BUSINESS:',
'MIGRATIONS:',
'PLANNING:',
'MINOR PLANNING:',
'MAJOR PLANNING:',
'MENTORSHIP:',
'MINOR MENTORSHIP:',
'MAJOR MENTORSHIP:',
'DISCUSSION:',
'MINOR DISCUSSION:',
'MAJOR DISCUSSION:',
'IMPORTS:',
'REVIEWS:',
'STATUS:'
];
const pullRequest = context.payload.pull_request;
if (!pullRequest) {
console.log('No pull request context available.');
return;
}
const title = context.payload.pull_request.title;
const existingLabels = context.payload.pull_request.labels.map(label => label.name);
for (const prefix of prefixes) {
if (title.startsWith(prefix)) {
const label = prefix.slice(0, -1);
if (!existingLabels.includes(label)) {
console.log(`Applying label: ${label}`);
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: [label]
});
}
break;
}
}
permissions:
contents: read
issues: write
pull-requests: write
requireIssueOrTask:
name: Require Issue Or Task Association
runs-on: ubuntu-latest
steps:
- name: Check out
uses: actions/checkout@v5
- name: Get PR Information
id: get_pr_info
uses: actions/github-script@v8
with:
script: >2-
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
const prOwner = pr.data.user.login || "";
const prBody = pr.data.body || "";
core.setOutput("prOwner", prOwner);
core.setOutput("description", prBody);
console.log(`PR Owner: ${prOwner}`);
console.log(`PR Body: ${prBody}`);
- name: Check For Associated Issues Or Tasks
id: check_for_issues_or_tasks
if: ${{ !contains(',dependabot[bot],', format(',{0},', steps.get_pr_info.outputs.prOwner)) }}
env:
PR_BODY: ${{ steps.get_pr_info.outputs.description }}
run: >2-
if [[ -z "${PR_BODY:-}" ]]; then
echo "Error: PR description does not contain any links to issue(s)/task(s) (e.g., 'closes #123' / 'closes AB#123' / 'fixes #123' / 'fixes AB#123')."
exit 1
fi
NORMALIZED_PR_BODY=$(printf '%s' "$PR_BODY" | tr '\r\n' ' ' | tr -s ' ')
if printf '%s' "$NORMALIZED_PR_BODY" | grep -Piq "(close|closes|closed|fix|fixes|fixed|resolve|resolves|resolved)\s*(\[#[0-9]+\]|#[0-9]+|\[AB#[0-9]+\]|AB#[0-9]+)"; then
echo "Valid PR description."
else
echo "Error: PR description does not contain any links to issue(s)/task(s) (e.g., 'closes #123' / 'closes AB#123' / 'fixes #123' / 'fixes AB#123')."
exit 1
fi
shell: bash
permissions:
contents: read
pull-requests: read
setAuthorAsPrAssignee:
name: Set Author As PR Assignee
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
steps:
- name: Set Author As PR Assignee
uses: actions/github-script@v8
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: >
const pr = context.payload.pull_request;
if (!pr) {
console.log('No pull request context available.');
return;
}
const author = pr.user.login;
if (author.endsWith('[bot]')) {
console.log(`Skipping bot author: ${author}`);
return;
}
console.log(`Assigning PR to author: ${author}`);
try {
await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
assignees: [author]
});
} catch (error) {
console.log(`Unable to assign ${author} as PR assignee: ${error.message}`);
}
permissions:
contents: read
issues: write
pull-requests: write