How to import data into GitHub project's view?

357 Views Asked by At

GitHub Projects provides Export view data options that export tasks into a tsv file. Does GitHub support reverse option, that is data import from tsv file? I'd like to avoid manual work of setting up my project :)

Export view data

1

There are 1 best solutions below

0
On

At the moment of writing this post the answer is No. Workaround was to:

  1. Create a blueprint file with tasks that I want to create - blueprint.tsv
  2. Run a seed script to create new items in project - project-seed.sh
  3. Manually edit tasks in GitHub Porject by editing table view - using ctrl+c, ctrl+v

Solution

blueprint.tsv

Title   Assignees   Status  Style   Chapter
A       Todo        01
B       Todo        01
C       Todo        01
D       Todo        01
E       Todo        01

project-seed.sh

#!/usr/bin/env bash

# Install GitHub CLI https://cli.github.com/manual/installation
# Login with `gh auth login`

function create_fields() {
  echo "Creting project's fields"
  fields=$(head -n1 $2)
  for field in $fields; do
    echo $field
    gh project field-create $1 --owner "@me" --name $field --data-type TEXT
  done
}

function create_items() {
  echo "Create project items"
  titles=$(tail -n +2 $2 | cut -f 1)
  for title in $titles; do
    echo $title
    gh project item-create $1 --owner "@me" --title $title
  done
}

# Static values
PROJECT_NO=2
TSV_PATH=~/Code/github/projects/blueprint.tsv

# Execute functions
create_fields $PROJECT_NO $TSV_PATH
create_items $PROJECT_NO $TSV_PATH

manual edit in table view

gh-project-table-view-edit