feat: about page with markdown #2
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
outputs: | |
sizeLabel: ${{ steps.size-label.outputs.sizeLabel }} | |
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 label = '${{ steps.size-label.outputs.sizeLabel }}'; | |
const color = labelsToColor[label]; | |
if (label) { | |
try { | |
// Check if the label already exists | |
await github.rest.issues.getLabel({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
name: label | |
}); | |
} 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: label, | |
color: color || 'b0b0b0', // Use gray as fallback 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: | | |
github.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." | |
}); |