Skip to content

website bug

website bug #15

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 = {
'1256082972403171338': 'profilarr',
'1256082994452762685': 'website',
'1256083006590947379': 'database',
'1256083018414686279': 'docs',
'1256083055853043854': '.github'
}
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)