Skip to content

SEGAM-77: TEST

SEGAM-77: TEST #7

Workflow file for this run

name: Create GitHub Issue from JIRA
on:
repository_dispatch:
types: [jira_issue_created]
issues:
types: [opened, edited]
jobs:
create-issue:
runs-on: ubuntu-latest
if: github.event_name == 'repository_dispatch'
steps:
- name: Create GitHub Issue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
JIRA_TOKEN: ${{ secrets.JIRA_API_TOKEN }}
uses: actions/github-script@v6
with:
script: |
// Jira to GitHub ๋งˆํฌ๋‹ค์šด ๋ณ€ํ™˜ ํ•จ์ˆ˜
function convertJiraToGitHub(text) {
if (!text) return text;
// ํ—ค๋”ฉ ๋ณ€ํ™˜
text = text.replace(/h([1-6])\.\s/g, (_, level) => '#'.repeat(level) + ' ');
// ์ฝ”๋“œ ๋ธ”๋ก ๋ณ€ํ™˜
text = text.replace(/{code(:([a-z]+))?}([\s\S]*?){code}/g, (_, __, lang, code) =>
'```' + (lang || '') + '\n' + code + '```'
);
// ํŒจ๋„ ๋ณ€ํ™˜
text = text.replace(/{panel}([\s\S]*?){panel}/g, '> $1');
// ์ธ์šฉ๊ตฌ ๋ณ€ํ™˜
text = text.replace(/bq\.\s/g, '> ');
// ๊ธ€๋จธ๋ฆฌ ๊ธฐํ˜ธ ๋ณ€ํ™˜
text = text.replace(/^\*\s/gm, '- ');
// ๋งํฌ ๋ณ€ํ™˜
text = text.replace(/\[([^\|]+)\|([^\]]+)\]/g, '[$1]($2)');
// ์ทจ์†Œ์„  ๋ณ€ํ™˜
text = text.replace(/-([^-]+)-/g, '~~$1~~');
// ๋ฐ‘์ค„ ๋ณ€ํ™˜
text = text.replace(/\+([^+]+)\+/g, '__$1__');
// ์ƒ‰์ƒ ํ…์ŠคํŠธ ๋ณ€ํ™˜
text = text.replace(/{color:[^}]+}([^{]+){color}/g, '`$1`');
// ํ‘œ ๋ณ€ํ™˜
text = text.replace(/\|\|([^\n]+)\|\|/g, '|$1|');
return text;
}
const { issue } = context.payload;
// JIRA ์„ค๋ช…์„ GitHub ๋งˆํฌ๋‹ค์šด์œผ๋กœ ๋ณ€ํ™˜
const convertedDescription = convertJiraToGitHub(issue.fields.description || 'No description');
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `[${issue.key}] ${issue.fields.summary}`,
body: `
Jira Issue: ${issue.key}
${convertedDescription}
---
Priority: ${issue.fields.priority?.name || 'Not set'}
Status: ${issue.fields.status.name}
[View in Jira](${process.env.JIRA_URL}/browse/${issue.key})
`
});
convert-markdown:
runs-on: ubuntu-latest
if: github.event_name == 'issues'
steps:
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Install Dependencies
run: npm install jira2md
- name: Convert Markdown
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const j2m = require('jira2md');
const issue = context.payload.issue;
if (!issue) return;
// Convert issue body using jira2md
const convertedBody = j2m.to_markdown(issue.body);
// Only update if the conversion changed the content
if (convertedBody !== issue.body) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
body: convertedBody
});
}