Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(ci): add auto label workflow (#290)

Will Hutchinsonfc9f19236db7
diff --git a/.github/workflows/assign-labels.yml b/.github/workflows/assign-labels.yml
new file mode 100644
index 0000000000..b491d55957
--- /dev/null
+++ b/.github/workflows/assign-labels.yml
@@ -0,0 +1,56 @@
+name: Auto Label PRs
+on:
+ pull_request:
+ types: [opened, synchronize, reopened]
+
+jobs:
+ label:
+ runs-on: ubuntu-latest
+ permissions:
+ contents: read
+ pull-requests: write
+ steps:
+ - name: Checkout code
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - name: Get changed files
+ id: changed-files
+ uses: tj-actions/changed-files@v44
+ - name: Label based on paths
+ uses: actions/github-script@v7
+ with:
+ github-token: ${{ secrets.GITHUB_TOKEN }}
+ script: |
+ const changedFiles = `${{ steps.changed-files.outputs.all_changed_files }}`.split(' ');
+ const labels = new Set();
+
+ // Define path-to-label mappings
+ const pathMappings = [
+ { path: 'rust/cloud-storage', label: 'cloud-storage' },
+ { path: 'js/app', label: 'web-app' },
+ { path: 'infra', label: 'infra' }
+ ];
+
+ // Check each changed file against path mappings
+ for (const file of changedFiles) {
+ for (const mapping of pathMappings) {
+ if (file.startsWith(mapping.path)) {
+ labels.add(mapping.label);
+ }
+ }
+ }
+
+ // Add labels to the PR
+ if (labels.size > 0) {
+ await github.rest.issues.addLabels({
+ owner: context.repo.owner,
+ repo: context.repo.repo,
+ issue_number: context.issue.number,
+ labels: Array.from(labels)
+ });
+
+ console.log(`Added labels: ${Array.from(labels).join(', ')}`);
+ } else {
+ console.log('No matching labels found for changed files');
+ }