From 23797fbf7b57d5af8ed91b1ed9e474a267aa5fd1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Nov 2025 14:19:59 +0000 Subject: [PATCH 1/6] Initial plan From df053a2997ef30939290a15a797829b17156085b Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Nov 2025 14:25:01 +0000 Subject: [PATCH 2/6] Add reusable workflow for managing repository labels Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- .github/workflows/manage-labels.yml | 15 +++ .github/workflows/reusable-manage-labels.yml | 126 +++++++++++++++++++ .github/workflows/sync-workflows.yml | 1 + 3 files changed, 142 insertions(+) create mode 100644 .github/workflows/manage-labels.yml create mode 100644 .github/workflows/reusable-manage-labels.yml diff --git a/.github/workflows/manage-labels.yml b/.github/workflows/manage-labels.yml new file mode 100644 index 0000000..13f4d27 --- /dev/null +++ b/.github/workflows/manage-labels.yml @@ -0,0 +1,15 @@ +--- +name: Manage Labels + +'on': + workflow_dispatch: + push: + branches: + - main + - master + paths: + - 'composer.json' + +jobs: + manage-labels: + uses: wp-cli/.github/.github/workflows/reusable-manage-labels.yml@main diff --git a/.github/workflows/reusable-manage-labels.yml b/.github/workflows/reusable-manage-labels.yml new file mode 100644 index 0000000..51b454a --- /dev/null +++ b/.github/workflows/reusable-manage-labels.yml @@ -0,0 +1,126 @@ +--- +name: Manage Repository Labels + +'on': + workflow_call: + +permissions: + issues: write + contents: read + +jobs: + manage-labels: + name: Create/Update Repository Labels + runs-on: ubuntu-latest + if: ${{ github.repository_owner == 'wp-cli' }} + steps: + - name: Check out source code + uses: actions/checkout@v5 + + - name: Set up PHP environment + uses: shivammathur/setup-php@v2 + with: + php-version: 'latest' + env: + COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Check existence of composer.json file + id: check_composer_file + uses: andstor/file-existence-action@v3 + with: + files: "composer.json" + + - name: Get commands from composer.json + id: get-commands + if: steps.check_composer_file.outputs.files_exists == 'true' + run: | + # Extract commands from composer.json using composer config + COMMANDS=$(composer config extra.commands 2>/dev/null || echo "[]") + echo "commands=${COMMANDS}" >> "$GITHUB_OUTPUT" + echo "Commands found: ${COMMANDS}" + + - name: Create/Update labels + uses: actions/github-script@v7 + env: + COMMANDS_JSON: ${{ steps.get-commands.outputs.commands }} + with: + script: | + // Standard labels that should exist in every repository + const standardLabels = [ + { name: 'good-first-issue', color: '7057ff', description: 'Good for newcomers' }, + { name: 'help-wanted', color: '008672', description: 'Extra attention is needed' }, + { name: 'scope:documentation', color: 'FEF2C0', description: 'Related to documentation' }, + { name: 'scope:testing', color: 'FEF2C0', description: 'Related to testing' } + ]; + + // Parse commands from composer.json + const commandsEnv = process.env.COMMANDS_JSON || '[]'; + let commands = []; + + try { + commands = JSON.parse(commandsEnv); + if (!Array.isArray(commands)) { + commands = []; + } + } catch (e) { + console.log('No commands found or invalid JSON format'); + commands = []; + } + + // Generate command-specific labels + const commandLabels = commands.map(command => { + // Convert command to label format: replace spaces with dashes + const labelName = 'command:' + command.replace(/\s+/g, '-'); + return { + name: labelName, + color: 'D4C5F9', + description: `Related to '${command}' command` + }; + }); + + // Combine all labels + const allLabels = [...standardLabels, ...commandLabels]; + + console.log(`Creating/updating ${allLabels.length} labels...`); + + // Create or update each label + for (const label of allLabels) { + try { + // Try to get existing label + try { + const existing = await github.rest.issues.getLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + name: label.name + }); + + // Update if it exists + await github.rest.issues.updateLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + name: label.name, + color: label.color, + description: label.description + }); + console.log(`✓ Updated label: ${label.name}`); + } catch (error) { + if (error.status === 404) { + // Create if it doesn't exist + await github.rest.issues.createLabel({ + owner: context.repo.owner, + repo: context.repo.repo, + name: label.name, + color: label.color, + description: label.description + }); + console.log(`✓ Created label: ${label.name}`); + } else { + throw error; + } + } + } catch (error) { + console.error(`✗ Failed to process label '${label.name}': ${error.message}`); + } + } + + console.log('Label management complete!'); diff --git a/.github/workflows/sync-workflows.yml b/.github/workflows/sync-workflows.yml index e4a7316..7d06dc4 100644 --- a/.github/workflows/sync-workflows.yml +++ b/.github/workflows/sync-workflows.yml @@ -24,6 +24,7 @@ jobs: ^.editorconfig ^.github/workflows/code-quality.yml ^.github/workflows/regenerate-readme.yml + ^.github/workflows/manage-labels.yml ^AGENTS.md TARGET_REPOS: | wp-cli/admin-command From 77c1266dc789671219f9e497e98a46dbb10de668 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Nov 2025 14:27:36 +0000 Subject: [PATCH 3/6] Add explicit permissions to manage-labels workflow Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- .github/workflows/manage-labels.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/manage-labels.yml b/.github/workflows/manage-labels.yml index 13f4d27..45711bd 100644 --- a/.github/workflows/manage-labels.yml +++ b/.github/workflows/manage-labels.yml @@ -10,6 +10,10 @@ name: Manage Labels paths: - 'composer.json' +permissions: + issues: write + contents: read + jobs: manage-labels: uses: wp-cli/.github/.github/workflows/reusable-manage-labels.yml@main From 5c5e12a38716469a9ced23d2df97d5b82877f9ac Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Nov 2025 14:33:40 +0000 Subject: [PATCH 4/6] Update command label color to C5DEF5 Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- .github/workflows/reusable-manage-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-manage-labels.yml b/.github/workflows/reusable-manage-labels.yml index 51b454a..eb970f4 100644 --- a/.github/workflows/reusable-manage-labels.yml +++ b/.github/workflows/reusable-manage-labels.yml @@ -73,7 +73,7 @@ jobs: const labelName = 'command:' + command.replace(/\s+/g, '-'); return { name: labelName, - color: 'D4C5F9', + color: 'C5DEF5', description: `Related to '${command}' command` }; }); From 905a4d017b123928c16b07219e3d0961760fcd1a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 13 Nov 2025 14:46:27 +0000 Subject: [PATCH 5/6] Remove unused 'existing' variable in label management Co-authored-by: swissspidy <841956+swissspidy@users.noreply.github.com> --- .github/workflows/reusable-manage-labels.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/reusable-manage-labels.yml b/.github/workflows/reusable-manage-labels.yml index eb970f4..839daaf 100644 --- a/.github/workflows/reusable-manage-labels.yml +++ b/.github/workflows/reusable-manage-labels.yml @@ -88,7 +88,7 @@ jobs: try { // Try to get existing label try { - const existing = await github.rest.issues.getLabel({ + await github.rest.issues.getLabel({ owner: context.repo.owner, repo: context.repo.repo, name: label.name From 09f918da23469a39c3f61698496ef847a1317787 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Wed, 10 Dec 2025 11:59:30 +0100 Subject: [PATCH 6/6] Add other default labels Co-authored-by: Alain Schlesser --- .github/workflows/reusable-manage-labels.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/reusable-manage-labels.yml b/.github/workflows/reusable-manage-labels.yml index 839daaf..786b19d 100644 --- a/.github/workflows/reusable-manage-labels.yml +++ b/.github/workflows/reusable-manage-labels.yml @@ -50,7 +50,10 @@ jobs: { name: 'good-first-issue', color: '7057ff', description: 'Good for newcomers' }, { name: 'help-wanted', color: '008672', description: 'Extra attention is needed' }, { name: 'scope:documentation', color: 'FEF2C0', description: 'Related to documentation' }, - { name: 'scope:testing', color: 'FEF2C0', description: 'Related to testing' } + { name: 'scope:testing', color: 'FEF2C0', description: 'Related to testing' }, + { name: 'scope:distribution', color: '5B7E7E', description: 'Related to distribution' }, + { name: 'status:unconfirmed', color: 'BFE5BF', description: 'Issue was could not be confirmed yet' }, + { name: 'status:unsupported', color: 'BFE5BF', description: 'Ask is not supported' } ]; // Parse commands from composer.json