refactor: RecordingInterfaceのコンポーネント分割 #15
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 Progress Automation | |
| on: | |
| pull_request: | |
| types: [opened, closed] | |
| env: | |
| # 進捗ラベル定義 | |
| PROGRESS_LABELS: '["todo", "in progress", "review", "done"]' | |
| jobs: | |
| manage-pr-progress: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| issues: write | |
| pull-requests: read | |
| contents: read | |
| steps: | |
| - name: Update linked issues on PR creation | |
| if: github.event.action == 'opened' | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const progressLabels = JSON.parse(process.env.PROGRESS_LABELS); | |
| const prBody = context.payload.pull_request.body || ''; | |
| // PR本文から関連IssueをRegular Expressionで抽出(Closes #123, Fixes #456, Resolves #789 など) | |
| const issueRegex = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/gi; | |
| const matches = [...prBody.matchAll(issueRegex)]; | |
| if (matches.length === 0) { | |
| console.log('ℹ️ No linked issues found in PR body'); | |
| return; | |
| } | |
| for (const match of matches) { | |
| const issueNumber = parseInt(match[1]); | |
| try { | |
| // 現在のIssueラベルを取得 | |
| const { data: issue } = await github.rest.issues.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber | |
| }); | |
| const currentLabels = issue.labels.map(label => label.name); | |
| const currentProgressLabels = currentLabels.filter(label => | |
| progressLabels.includes(label) | |
| ); | |
| // 既存の進捗ラベルを削除 | |
| for (const label of currentProgressLabels) { | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| name: label | |
| }); | |
| console.log(`🗑️ Removed '${label}' label from issue #${issueNumber}`); | |
| } | |
| // 'review'ラベルを追加 | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| labels: ['review'] | |
| }); | |
| console.log(`✅ Added 'review' label to issue #${issueNumber} (linked to PR #${context.issue.number})`); | |
| } catch (error) { | |
| console.error(`❌ Failed to update issue #${issueNumber}:`, error.message); | |
| } | |
| } | |
| - name: Update linked issues on PR merge | |
| if: github.event.action == 'closed' && github.event.pull_request.merged == true | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const progressLabels = JSON.parse(process.env.PROGRESS_LABELS); | |
| const prBody = context.payload.pull_request.body || ''; | |
| // PR本文から関連Issueを抽出 | |
| const issueRegex = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/gi; | |
| const matches = [...prBody.matchAll(issueRegex)]; | |
| if (matches.length === 0) { | |
| console.log('ℹ️ No linked issues found in PR body'); | |
| return; | |
| } | |
| for (const match of matches) { | |
| const issueNumber = parseInt(match[1]); | |
| try { | |
| // 現在のIssueラベルを取得 | |
| const { data: issue } = await github.rest.issues.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber | |
| }); | |
| const currentLabels = issue.labels.map(label => label.name); | |
| const currentProgressLabels = currentLabels.filter(label => | |
| progressLabels.includes(label) | |
| ); | |
| // 既存の進捗ラベルを削除 | |
| for (const label of currentProgressLabels) { | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| name: label | |
| }); | |
| console.log(`🗑️ Removed '${label}' label from issue #${issueNumber}`); | |
| } | |
| // 'done'ラベルを追加 | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| labels: ['done'] | |
| }); | |
| console.log(`✅ Added 'done' label to issue #${issueNumber} (PR #${context.issue.number} merged)`); | |
| } catch (error) { | |
| console.error(`❌ Failed to update issue #${issueNumber}:`, error.message); | |
| } | |
| } | |
| - name: Revert linked issues on PR close without merge | |
| if: github.event.action == 'closed' && github.event.pull_request.merged == false | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const progressLabels = JSON.parse(process.env.PROGRESS_LABELS); | |
| const prBody = context.payload.pull_request.body || ''; | |
| // PR本文から関連IssueをRegular Expressionで抽出(Closes #123, Fixes #456, Resolves #789 など) | |
| const issueRegex = /(?:close[sd]?|fix(?:e[sd])?|resolve[sd]?)\s+#(\d+)/gi; | |
| const matches = [...prBody.matchAll(issueRegex)]; | |
| if (matches.length === 0) { | |
| console.log('ℹ️ No linked issues found in PR body'); | |
| return; | |
| } | |
| for (const match of matches) { | |
| const issueNumber = parseInt(match[1]); | |
| try { | |
| // 現在のIssueラベルを取得 | |
| const { data: issue } = await github.rest.issues.get({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber | |
| }); | |
| const currentLabels = issue.labels.map(label => label.name); | |
| const currentProgressLabels = currentLabels.filter(label => | |
| progressLabels.includes(label) | |
| ); | |
| // reviewラベルがある場合のみ処理 | |
| if (!currentProgressLabels.includes('review')) { | |
| console.log(`ℹ️ Issue #${issueNumber} is not in review status, skipping`); | |
| continue; | |
| } | |
| // 既存の進捗ラベルを削除 | |
| for (const label of currentProgressLabels) { | |
| await github.rest.issues.removeLabel({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| name: label | |
| }); | |
| console.log(`🗑️ Removed '${label}' label from issue #${issueNumber}`); | |
| } | |
| // アサインされている場合は'in progress'、そうでなければ'todo' | |
| const statusLabel = (issue.assignees && issue.assignees.length > 0) ? 'in progress' : 'todo'; | |
| await github.rest.issues.addLabels({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| labels: [statusLabel] | |
| }); | |
| console.log(`✅ Added '${statusLabel}' label to issue #${issueNumber} (PR #${context.issue.number} closed without merge)`); | |
| } catch (error) { | |
| console.error(`❌ Failed to update issue #${issueNumber}:`, error.message); | |
| } | |
| } |