이슈 테스트 #3
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: Add issues to project | |
| on: | |
| issues: | |
| types: [opened, reopened] | |
| jobs: | |
| add-to-project: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Add issue to project | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.PROJECT_TOKEN || secrets.GITHUB_TOKEN }} | |
| script: | | |
| const ownerLogin = 'YAPP-Github'; | |
| const projectNumber = 29; | |
| const contentId = context.payload.issue.node_id; | |
| // Step 1: Get project ID (try organization first, then user) | |
| const getOrgProjectQuery = ` | |
| query($login: String!, $number: Int!) { | |
| organization(login: $login) { | |
| projectV2(number: $number) { | |
| id | |
| } | |
| } | |
| } | |
| `; | |
| const getUserProjectQuery = ` | |
| query($login: String!, $number: Int!) { | |
| user(login: $login) { | |
| projectV2(number: $number) { | |
| id | |
| } | |
| } | |
| } | |
| `; | |
| let projectId; | |
| // Try organization project first | |
| try { | |
| const projectResult = await github.graphql(getOrgProjectQuery, { | |
| login: ownerLogin, | |
| number: projectNumber | |
| }); | |
| projectId = projectResult.organization.projectV2.id; | |
| console.log('Found organization project ID:', projectId); | |
| } catch (orgError) { | |
| console.log('Not an organization project, trying user project...'); | |
| // Try user project | |
| try { | |
| const projectResult = await github.graphql(getUserProjectQuery, { | |
| login: ownerLogin, | |
| number: projectNumber | |
| }); | |
| projectId = projectResult.user.projectV2.id; | |
| console.log('Found user project ID:', projectId); | |
| } catch (userError) { | |
| console.error('Error fetching project ID from both org and user:', { | |
| orgError: orgError.message, | |
| userError: userError.message | |
| }); | |
| throw new Error(`Could not find project #${projectNumber} for ${ownerLogin}`); | |
| } | |
| } | |
| // Step 2: Add issue to project | |
| const addToProjectMutation = ` | |
| mutation($projectId: ID!, $contentId: ID!) { | |
| addProjectV2ItemById(input: {projectId: $projectId, contentId: $contentId}) { | |
| item { | |
| id | |
| } | |
| } | |
| } | |
| `; | |
| try { | |
| const result = await github.graphql(addToProjectMutation, { | |
| projectId: projectId, | |
| contentId: contentId | |
| }); | |
| console.log('Successfully added issue to project:', result); | |
| } catch (error) { | |
| console.error('Error adding issue to project:', error); | |
| throw error; | |
| } |