diff --git a/.github/workflows/setup-project-board.yml b/.github/workflows/setup-project-board.yml new file mode 100644 index 0000000..663cc85 --- /dev/null +++ b/.github/workflows/setup-project-board.yml @@ -0,0 +1,67 @@ +name: Setup Project Board +on: + workflow_dispatch: + +permissions: + repository-projects: write + +jobs: + setup-board: + runs-on: ubuntu-latest + steps: + - name: Create project board with columns + uses: actions/github-script@v7 + with: + script: | + const columns = [ + 'Backlog', + 'Ready for Agent', + 'In Progress', + 'Review', + 'Done' + ]; + + // Check for an existing board named 'Board' + const { data: existingProjects } = await github.rest.projects.listForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + }); + + let project; + const existing = existingProjects.find(p => p.name === 'Board'); + if (existing) { + console.log(`Using existing project: ${existing.name} (id: ${existing.id})`); + project = existing; + } else { + const created = await github.rest.projects.createForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + name: 'Board', + }); + console.log(`Created project: ${created.data.name} (id: ${created.data.id})`); + project = created.data; + } + + // Add columns in order, skipping any that already exist + const { data: existingColumns } = await github.rest.projects.listColumns({ + project_id: project.id, + }); + const existingNames = new Set(existingColumns.map(c => c.name)); + + for (const name of columns) { + if (existingNames.has(name)) { + console.log(`Column already exists, skipping: ${name}`); + continue; + } + try { + await github.rest.projects.createColumn({ + project_id: project.id, + name, + }); + console.log(`Created column: ${name}`); + } catch (err) { + core.setFailed(`Failed to create column "${name}": ${err.message}`); + return; + } + }