Skip to content

Instantly share code, notes, and snippets.

@tichnas
Last active July 6, 2021 20:03
Show Gist options
  • Select an option

  • Save tichnas/14d254e24c805c57cdb6d905e21bddfb to your computer and use it in GitHub Desktop.

Select an option

Save tichnas/14d254e24c805c57cdb6d905e21bddfb to your computer and use it in GitHub Desktop.
Duplicate milestones from one repo to another.
#!/bin/bash
source="$1"
destination="$2"
cwd="$PWD"
cd "$source"
milestones=$(gh listMilestones | jq ".data.repository.milestones.nodes" | jq -c ".[]")
cd "$cwd"
cd "$destination"
for milestone in $milestones; do
parsed=$(echo $milestone | jq -c "{title: .title, state: .state | ascii_downcase, due_on: .dueOn, description: .description}")
echo "$parsed" | gh createMilestone
done
cd "$cwd"
@tichnas
Copy link
Author

tichnas commented May 18, 2021

Prerequisites:

  1. Install jq: https://stedolan.github.io/jq/
  2. https://gist.github.com/doi-t/5735f9f0f7f8b7664aa6739bc810a2cc

Usage:

./duplicateMilestones.sh <source> <destination>, where <source> and <destination> are paths of source repo and destination repo respectively.

Setting permanent gh alias

  1. Copy full script
  2. Run gh alias set --shell replicateMilestones '<paste>' (don't forget the quotes around the whole script)
  3. Usage: gh replicateMilestones <source> <destination>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment