Skip to content

Instantly share code, notes, and snippets.

@gadelkareem
Forked from potter0815/cloneall.sh
Last active November 28, 2019 13:10
Show Gist options
  • Select an option

  • Save gadelkareem/cc1d3e27de239f691cbe720b5b28797b to your computer and use it in GitHub Desktop.

Select an option

Save gadelkareem/cc1d3e27de239f691cbe720b5b28797b to your computer and use it in GitHub Desktop.

Revisions

  1. gadelkareem renamed this gist Nov 28, 2019. 1 changed file with 12 additions and 4 deletions.
    16 changes: 12 additions & 4 deletions cloneall.sh → cloneorpull.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,6 @@
    #!/bin/bash
    #requires jq -> http://stedolan.github.io/jq/

    set -euo pipefail
    set -e

    #optional change working directory
    DIR=${1-$(pwd)}
    @@ -11,6 +10,7 @@ USER="Github username"
    TOKEN=$GITHUB_TOKEN
    ORGANIZATION="organization name"


    REPOS=$(curl -s https://api.github.com/orgs/$ORGANIZATION/repos?type=private\&per_page=1000 -u ${USER}:${TOKEN} | jq .[].ssh_url | sed -e 's/^"//' -e 's/"$//')

    for repo in $REPOS
    @@ -20,9 +20,17 @@ do
    ret=0
    git clone $repo 2> /dev/null || ret=1
    if [ $ret -ne 0 ]; then
    repo=`echo $repo | sed 's/.*\///' | sed 's/\.git//' `
    repo_dir=`echo $repo | sed 's/.*\///' | sed 's/\.git//' `
    if [ ! -d $repo_dir ]; then
    echo "Error: Failed to clone $repo"
    fi
    fi
    done


    for repo in */ ; do
    echo "Pulling changes for $repo"
    cd $repo
    git pull &
    cd ..
    fi
    done
  2. gadelkareem revised this gist Nov 25, 2019. No changes.
  3. gadelkareem revised this gist Nov 25, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions cloneall.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,8 @@
    #!/bin/bash
    #requires jq -> http://stedolan.github.io/jq/

    set -euo pipefail

    #optional change working directory
    DIR=${1-$(pwd)}
    cd $DIR
  4. gadelkareem revised this gist Nov 25, 2019. 1 changed file with 16 additions and 10 deletions.
    26 changes: 16 additions & 10 deletions cloneall.sh
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,26 @@
    #!/bin/bash
    #requires jq -> http://stedolan.github.io/jq/

    #optional change working_dir
    working_dir=${1-$(pwd)}
    cd $working_dir
    #optional change working directory
    DIR=${1-$(pwd)}
    cd $DIR

    user="github_username"
    token="application token"
    organization="Organization_Name"
    USER="Github username"
    TOKEN=$GITHUB_TOKEN
    ORGANIZATION="organization name"

    REPOS=$(curl -s https://api.github.com/orgs/$ORGANIZATION/repos?type=private\&per_page=1000 -u ${USER}:${TOKEN} | jq .[].ssh_url | sed -e 's/^"//' -e 's/"$//')

    repo_list=$(curl https://api.github.com/orgs/$organization/repos?type=private\&per_page=100 -u ${user}:${token} | jq .[].ssh_url | sed -e 's/^"//' -e 's/"$//')

    for repo in $repo_list
    for repo in $REPOS
    do

    echo "Repo found: $repo"
    git clone $repo
    ret=0
    git clone $repo 2> /dev/null || ret=1
    if [ $ret -ne 0 ]; then
    repo=`echo $repo | sed 's/.*\///' | sed 's/\.git//' `
    cd $repo
    git pull &
    cd ..
    fi
    done
  5. @potter0815 potter0815 revised this gist May 17, 2015. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions cloneall.sh
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,9 @@
    #!/bin/bash
    #requires jq -> http://stedolan.github.io/jq/

    #optional change working_dir
    working_dir=${1-$(pwd)}
    cd $working_dir

    user="github_username"
    token="application token"
  6. @potter0815 potter0815 created this gist May 16, 2015.
    17 changes: 17 additions & 0 deletions cloneall.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    #!/bin/bash
    #requires jq -> http://stedolan.github.io/jq/


    user="github_username"
    token="application token"
    organization="Organization_Name"


    repo_list=$(curl https://api.github.com/orgs/$organization/repos?type=private\&per_page=100 -u ${user}:${token} | jq .[].ssh_url | sed -e 's/^"//' -e 's/"$//')

    for repo in $repo_list
    do

    echo "Repo found: $repo"
    git clone $repo
    done