mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
Add platform label
This commit is contained in:
39
.github/workflows/labeled.yml
vendored
Normal file
39
.github/workflows/labeled.yml
vendored
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
name: Issue Labeled
|
||||||
|
env:
|
||||||
|
BUN_VERSION: 1.1.13
|
||||||
|
|
||||||
|
on:
|
||||||
|
issues:
|
||||||
|
types: [labeled]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
reply-labeled:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.event.label.name == 'crash'
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
sparse-checkout: |
|
||||||
|
scripts
|
||||||
|
.github
|
||||||
|
- name: Setup Bun
|
||||||
|
uses: ./.github/actions/setup-bun
|
||||||
|
with:
|
||||||
|
bun-version: ${{ env.BUN_VERSION }}
|
||||||
|
- name: "add platform and command label"
|
||||||
|
id: add-labels
|
||||||
|
env:
|
||||||
|
GITHUB_ISSUE_BODY: ${{ github.event.issue.body }}
|
||||||
|
GITHUB_ISSUE_TITLE: ${{ github.event.issue.title }}
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
LABELS=$(bun scripts/read-issue.ts)
|
||||||
|
echo "labels=$LABELS" >> $GITHUB_OUTPUT
|
||||||
|
- name: Add labels
|
||||||
|
uses: actions-cool/issues-helper@v3
|
||||||
|
with:
|
||||||
|
actions: 'add-labels'
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-number: ${{ github.event.issue.number }}
|
||||||
|
labels: ${{ steps.add-labels.outputs.labels }}
|
||||||
56
scripts/read-issue.ts
Normal file
56
scripts/read-issue.ts
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
const body = process.env.GITHUB_ISSUE_BODY;
|
||||||
|
|
||||||
|
if (!body) {
|
||||||
|
throw new Error("GITHUB_ISSUE_BODY must be set");
|
||||||
|
}
|
||||||
|
|
||||||
|
const labels: string[] = [];
|
||||||
|
let command = "";
|
||||||
|
if (body.includes("[TestCommand]")) {
|
||||||
|
command = "jest";
|
||||||
|
} else if (body.includes("[BuildCommand]")) {
|
||||||
|
command = "bundler";
|
||||||
|
} else if (body.includes("[InstallCommand]") || body.includes("[AddCommand]") || body.includes("[RemoveCommand]")) {
|
||||||
|
command = "npm";
|
||||||
|
}
|
||||||
|
|
||||||
|
let featuresLine = "";
|
||||||
|
const featuresI = body.indexOf("\nFeatures: ");
|
||||||
|
const featuresEndI = body.indexOf("\n", featuresI + 1);
|
||||||
|
if (featuresI > -1 && featuresEndI > -1) {
|
||||||
|
featuresLine = body.slice(featuresI + 1, featuresEndI).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
const features = featuresLine.split(" ").map(a => a.trim().toLowerCase());
|
||||||
|
|
||||||
|
if (features.includes("jsc")) {
|
||||||
|
labels.push("runtime");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (features.includes("shell")) {
|
||||||
|
labels.push("shell");
|
||||||
|
}
|
||||||
|
|
||||||
|
const lines = body.split("\n");
|
||||||
|
for (const line of lines) {
|
||||||
|
if (line.startsWith("Bun v") && line.includes(" on ")) {
|
||||||
|
const onI = line.indexOf(" on ");
|
||||||
|
const onI2 = line.indexOf("\n", onI + 1);
|
||||||
|
const on = line
|
||||||
|
.slice(onI + 4, onI2 > -1 ? onI2 : undefined)
|
||||||
|
.trim()
|
||||||
|
.toLowerCase();
|
||||||
|
|
||||||
|
if (on.includes("macos") || on.includes("darwin")) {
|
||||||
|
labels.push("macos");
|
||||||
|
} else if (on.includes("linux")) {
|
||||||
|
labels.push("linux");
|
||||||
|
} else if (on.includes("windows") || on.includes("nt")) {
|
||||||
|
labels.push("windows");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (labels.length > 0) {
|
||||||
|
console.write(labels.join(",") + "\n");
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user