Fixed badges light mode issue and container gradient color in Companies tab in "recodehive.com/interview-prep". #501
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: PR Issue Sync | |
| on: | |
| workflow_dispatch: {} # manual trigger only (disables automatic runs) | |
| jobs: | |
| sync-metadata: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| issues: write | |
| pull-requests: write | |
| steps: | |
| - name: Extract Linked Issues | |
| id: extract | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const body = context.payload.pull_request.body || ""; | |
| const issuePattern = /#(\d+)/g; | |
| let matches = []; | |
| let m; | |
| while ((m = issuePattern.exec(body)) !== null) { | |
| matches.push(parseInt(m[1])); | |
| } | |
| core.setOutput("issues", JSON.stringify(matches)); | |
| - name: Sync metadata | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const data = ${{ fromJSON(format('{{\"issues\":{0},\"pr\":{1}}}', steps.extract.outputs.issues, github.event.pull_request.number)) }}; | |
| 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}`); | |
| } | |
| // --- 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); | |
| } | |
| } |