Skip to content

feat: custom NotFound and OnError middleware #30

feat: custom NotFound and OnError middleware

feat: custom NotFound and OnError middleware #30

Workflow file for this run

name: size-label
on:
pull_request_target:
types: [opened, synchronize]
jobs:
size-label:
permissions:
contents: read
pull-requests: write
issues: write
runs-on: ubuntu-latest
steps:
- name: 🛎️ Checkout repository
uses: actions/checkout@v4
- name: Determine PR size and add label
id: size-label
uses: pascalgn/size-label-action@v0.5.5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
IGNORED: |
yarn.lock
.pnp.*
dist/**
build/**
.cache/**
with:
sizes: >
{
"0": "XS",
"20": "S",
"50": "M",
"200": "L",
"800": "XL",
"2000": "XXL"
}
- name: Set label colors
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const labelsToColor = {
XS: 'd4c5f9', // Light purple
S: 'c2e0c6', // Light green
M: 'f9d0c4', // Light red
L: 'f7c6c7', // Light pink
XL: 'fef2c0', // Light yellow
XXL: 'e99695', // Light coral
};
const sizeLabel = ${{ steps.size-label.outputs.sizeLabel }};
const color = labelsToColor[sizeLabel];
if (sizeLabel) {
try {
// Check if the label already exists
await github.rest.issues.getLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: sizeLabel,
});
} catch (error) {
// If label doesn't exist, create it with the specified color
await github.rest.issues.createLabel({
owner: context.repo.owner,
repo: context.repo.repo,
name: sizeLabel,
color: color || 'b0b0b0', // Default to gray if no color is found
});
}
}
- name: Comment on large PRs
if: ${{ contains(steps.size-label.outputs.sizeLabel, 'XL') }}
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: "This PR is too large and may need to be broken into smaller pieces."
});