Skip to content

Commit

Permalink
Modify where we create the project
Browse files Browse the repository at this point in the history
  • Loading branch information
bordoni committed Feb 18, 2024
1 parent 8f1ed4e commit f0e54c6
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
6 changes: 3 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 8 additions & 5 deletions src/project-link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@ interface ProjectNodeIDResponse {
}
}

interface UserResponse {
interface OwnerResponse {
user?: {
id: string
}
organization?: {
id: string
}
}

interface ProjectNode {
Expand Down Expand Up @@ -220,22 +223,22 @@ export async function projectLink(): Promise<void> {
core.info(`Found project: ${project.title} (Number: ${project.number})(ID: ${project.id})`)
} else {
const getOwnerQuery = `query {
user(login:"${projectOwner}") {
${ownerType}(login:"${templateProjectOwnerName}") {
id
}
}`
core.debug(`Project Owner Query: \n ${getOwnerQuery}`)

// First, use the GraphQL API to request the template project's node ID.
const ownerResp = await octokit.graphql<UserResponse>(getOwnerQuery)
const ownerResp = await octokit.graphql<OwnerResponse>(getOwnerQuery)

core.debug(`Owner Response: \n ${JSON.stringify(ownerResp, null, 2)}`)

if (!ownerResp?.user?.id) {
if (!ownerResp[ownerType]?.id) {
throw new Error(`No owner found for ${projectOwner}`)
}

const projectOwnerID = ownerResp?.user?.id
const projectOwnerID = ownerResp[ownerType]?.id

const copyProjectTemplateResp = await octokit.graphql<ProjectCopyTemplateResponse>(
`mutation createProjectFromTemplate($input: CopyProjectV2Input!) {
Expand Down

0 comments on commit f0e54c6

Please sign in to comment.