Skip to content

[BE] 질문 데이터를 조회&삭제하는 과정에서 발생하는 문제 해결 #28

[BE] 질문 데이터를 조회&삭제하는 과정에서 발생하는 문제 해결

[BE] 질문 데이터를 조회&삭제하는 과정에서 발생하는 문제 해결 #28

Workflow file for this run

name: PR Opened - Assign & Add to Project
on:
pull_request:
types: [opened]
workflow_dispatch:
permissions:
issues: write
pull-requests: write
repository-projects: write
jobs:
pr-open:
runs-on: ubuntu-latest
steps:
- name: Assign PR Creator
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_PAT }}
script: |
github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
assignees: [context.payload.pull_request.user.login]
});
- name: Add PR to Team3-PowerPenguin Project & Set Start Date
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_PAT }}
script: |
const projectId = "PVT_kwDOC1gbws4Aw4Qy";
const statusFieldId = "PVTSSF_lADOC1gbws4Aw4QyzgnFD7w";
const inReviewOptionId = "554de2e0";
const startDateFieldId = "PVTF_lADOC1gbws4Aw4QyzgnFEDA";
const prId = context.payload.pull_request.node_id;
const addToProject = await github.graphql(`
mutation {
addProjectV2ItemById(input: { projectId: "${projectId}", contentId: "${prId}" }) {
item { id }
}
}
`);
const itemId = addToProject.addProjectV2ItemById.item.id;
await github.graphql(`
mutation {
updateProjectV2ItemFieldValue(input: {
projectId: "${projectId}",
itemId: "${itemId}",
fieldId: "${statusFieldId}",
value: { singleSelectOptionId: "${inReviewOptionId}" }
}) {
clientMutationId
}
}
`);
const startDate = new Date().toISOString();
await github.graphql(`
mutation {
updateProjectV2ItemFieldValue(input: {
projectId: "${projectId}",
itemId: "${itemId}",
fieldId: "${startDateFieldId}",
value: { date: "${startDate}" }
}) {
clientMutationId
}
}
`);
- name: Set PR & Linked Issues to In-Review
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GH_PAT }}
script: |
const prNumber = context.payload.pull_request.number;
const { data: linkedIssues } = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: "open",
labels: [`pr-${prNumber}`]
});
for (const issue of linkedIssues) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issue.number,
state: "open",
labels: [...issue.labels.map(l => l.name), "In-Review"]
});
}