Fixed the Pill badge color issue which forced the dark grey color on the badges and Companies tab which pushed the gradient grey color. #113
Workflow file for this run
This file contains hidden or 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: Sync Issue Metadata to PR | |
| on: | |
| pull_request_target: | |
| types: [opened, edited, synchronize, reopened] | |
| permissions: | |
| pull-requests: write | |
| issues: write | |
| contents: read | |
| repository-projects: write | |
| jobs: | |
| sync-pr-metadata: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Extract linked issue(s) from PR | |
| id: extract-issues | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const prNumber = context.payload.pull_request.number; | |
| const prTitle = context.payload.pull_request.title || ''; | |
| const prBody = context.payload.pull_request.body || ''; | |
| // Regex patterns for issue references | |
| const patterns = [ | |
| /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/gi, | |
| /#(\d+)/g | |
| ]; | |
| const issueNumbers = new Set(); | |
| const text = prTitle + ' ' + prBody; | |
| for (const pattern of patterns) { | |
| for (const match of text.matchAll(pattern)) { | |
| issueNumbers.add(match[1]); | |
| } | |
| } | |
| return JSON.stringify({ issues: Array.from(issueNumbers), pr: prNumber }); | |
| - name: Sync Issue Metadata to PR | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const data = JSON.parse('${{ steps.extract-issues.outputs.result }}'); | |
| const prNumber = data.pr; | |
| const issueNumbers = data.issues || []; | |
| if (issueNumbers.length === 0) { | |
| console.log("No linked issues found"); | |
| return; | |
| } | |
| for (const issueNumber of issueNumbers) { | |
| try { | |
| // Fetch issue | |
| const { data: issue } = await github.rest.issues.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: parseInt(issueNumber) | |
| }); | |
| console.log(`Syncing metadata from Issue #${issueNumber} to PR #${prNumber}`); | |
| // --- Sync Labels --- | |
| const issueLabels = issue.labels.map(l => l.name); | |
| const { data: pr } = await github.rest.pulls.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: prNumber | |
| }); | |
| const currentPRLabels = pr.labels.map(l => l.name); | |
| const combinedLabels = Array.from(new Set([...currentPRLabels, ...issueLabels])); | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| labels: combinedLabels | |
| }); | |
| console.log(`Labels applied: ${combinedLabels.join(', ')}`); | |
| // --- Sync Milestone --- | |
| if (issue.milestone) { | |
| await github.rest.issues.update({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| milestone: issue.milestone.number | |
| }); | |
| console.log(`Milestone synced: ${issue.milestone.title}`); | |
| } | |
| // --- Sync Projects (GitHub Projects v2) --- | |
| if(issue.project_cards_url) { | |
| // Fetch project cards of issue | |
| const cardsResponse = await github.rest.projects.listCards({ | |
| column_id: issue.project_cards_url.split('/').pop() // last part is column_id | |
| }).catch(()=>({data:[]})); | |
| for(const card of cardsResponse.data || []) { | |
| await github.rest.projects.createCard({ | |
| column_id: card.column_id, | |
| content_id: prNumber, | |
| content_type: 'PullRequest' | |
| }); | |
| console.log(`Added PR #${prNumber} to project card in column ${card.column_id}`); | |
| } | |
| } | |
| // --- Optionally: Add a comment on PR --- | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: prNumber, | |
| body: `✅ Synchronized metadata from Issue #${issueNumber}:\nLabels: ${issueLabels.join(', ')}\nMilestone: ${issue.milestone ? issue.milestone.title : 'None'}` | |
| }); | |
| } catch (error) { | |
| console.error(`Error syncing issue #${issueNumber} to PR #${prNumber}:`, error.message); | |
| } | |
| } |