Skip to content

feat: SEO - dynamic sitemap and robots.txt #30

feat: SEO - dynamic sitemap and robots.txt

feat: SEO - dynamic sitemap and robots.txt #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: Determine PR size and add label
id: size-label
uses: 'pascalgn/[email protected]'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
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 = core.getInput('size-label-output') || '${{ 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') || contains(steps.size-label.outputs.sizeLabel, 'XXL') }}
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."
});