Database Table: Quality Groupings #45
This file contains 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: Transfer Issue | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
transfer-issue: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Transfer issue | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.PERSONAL_ACCESS_TOKEN}} | |
script: | | |
const issue = context.payload.issue | |
const body = issue.body | |
// Extract the tag ID from the body | |
const tagMatch = body.match(/Tags:\s*\n(\d+)/) | |
if (tagMatch) { | |
const tagId = tagMatch[1] | |
// Map tag IDs to repo names | |
const tagToRepo = { | |
'1257151213439549561': 'profilarr', | |
'1257153568000184371': 'profilarr', | |
'1257151164395552930': 'website', | |
'1257153522340991116': 'website', | |
'1257151182250573846': 'database', | |
'1257153547225534655': 'database', | |
'1257151231663673446': 'docs', | |
'1257153587004309535': 'docs' | |
} | |
const destRepo = tagToRepo[tagId] | |
if (destRepo) { | |
try { | |
// Create a new issue in the destination repo | |
const newIssue = await github.rest.issues.create({ | |
owner: 'Dictionarry-Hub', | |
repo: destRepo, | |
title: issue.title, | |
body: `${issue.body}\n\nTransferred from ${context.repo.owner}/${context.repo.repo}#${issue.number}`, | |
labels: issue.labels.map(label => label.name) | |
}) | |
// Close the original issue | |
await github.rest.issues.update({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: issue.number, | |
state: 'closed', | |
state_reason: 'completed' | |
}) | |
console.log(`Issue transferred to ${destRepo}. New issue number: ${newIssue.data.number}`) | |
} catch (error) { | |
console.error(`Error transferring issue: ${error.message}`) | |
} | |
} else { | |
console.log(`No matching repo found for tag ID: ${tagId}`) | |
} | |
} else { | |
console.log('No tag found in issue body') | |
} | |
// Log the entire issue body for debugging | |
console.log('Issue body:', body) |