Skip to content

Prepare AWS deployment scripts #30

Prepare AWS deployment scripts

Prepare AWS deployment scripts #30

name: NetLicensing MCP - Labeler
on:
pull_request:
types: [opened, edited, synchronize, reopened]
push:
branches: [master]
permissions:
contents: read
pull-requests: write
issues: write
jobs:
# ── Label PRs by branch name and changed files ─────────────────────────────
label-pr:
name: Label Pull Request
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/labeler@v5
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
configuration-path: .github/labeler.yml
sync-labels: true
# ── Label PRs by PR title (conventional commits style) ─────────────────────
label-pr-title:
name: Label by PR Title
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/github-script@v7
with:
script: |
const title = context.payload.pull_request.title.toLowerCase();
const number = context.payload.pull_request.number;
const labels = [];
const rules = [
{ pattern: /^feat(\(.+\))?!?:/, label: 'enhancement' },
{ pattern: /^fix(\(.+\))?!?:/, label: 'bug' },
{ pattern: /^docs(\(.+\))?:/, label: 'documentation' },
{ pattern: /^chore(\(.+\))?:/, label: 'chore' },
{ pattern: /^ci(\(.+\))?:/, label: 'ci' },
{ pattern: /^refactor(\(.+\))?:/, label: 'refactor' },
{ pattern: /^test(\(.+\))?:/, label: 'testing' },
{ pattern: /^perf(\(.+\))?:/, label: 'performance' },
{ pattern: /^build(\(.+\))?:/, label: 'dependencies' },
{ pattern: /^mcp(\(.+\))?:/, label: 'mcp' },
{ pattern: /^api(\(.+\))?:/, label: 'api' },
{ pattern: /!:/, label: 'breaking-change' },
];
for (const rule of rules) {
if (rule.pattern.test(title)) labels.push(rule.label);
}
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: number,
labels,
});
}
# ── Label merged PRs from commits pushed to main ───────────────────────────
label-commit-prs:
name: Label merged PRs from commits
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/github-script@v7
with:
script: |
const commits = context.payload.commits || [];
for (const commit of commits) {
const msg = commit.message.toLowerCase();
const { data: prs } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: commit.id,
});
for (const pr of prs) {
const labels = [];
const rules = [
{ pattern: /^feat/, label: 'enhancement' },
{ pattern: /^fix/, label: 'bug' },
{ pattern: /^docs/, label: 'documentation' },
{ pattern: /^ci/, label: 'ci' },
{ pattern: /^chore/, label: 'chore' },
{ pattern: /^refactor/, label: 'refactor' },
{ pattern: /^test/, label: 'testing' },
{ pattern: /^build/, label: 'dependencies' },
{ pattern: /^mcp/, label: 'mcp' },
{ pattern: /^api/, label: 'api' },
{ pattern: /!/, label: 'breaking-change' },
];
for (const rule of rules) {
if (rule.pattern.test(msg)) labels.push(rule.label);
}
if (labels.length > 0) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pr.number,
labels,
}).catch(() => {});
}
}
}