Home | History | Annotate | Download | only in build
      1 #!/usr/bin/env bash
      2 
      3 ##############################################################################
      4 ##
      5 ##  GitHub Upate script for Android Samples
      6 ##
      7 ##############################################################################
      8 
      9 ##replace with auth token for google-automerger GitHub account
     10 TOKEN=herpderp
     11 
     12 ##make temporary dir to pull code into - delete at end.
     13 mkdir github-temp
     14 cd github-temp
     15 
     16 ##iterate through samples
     17 for i in $(ls ../prebuilts/gradle);
     18 
     19 
     20 ##for testing
     21 #foo="ActionBarCompat-Basic"
     22 #foo="ActionBarCompat-Basic herpderp"
     23 #foo="ActionBarCompat-Basic ActionBarCompat-ListPopupMenu"
     24 #foo="MediaBrowserService MessagingService"
     25 #for i in $foo;
     26 
     27 do
     28 echo "
     29 $i"
     30 
     31 URL=https://github.com/googlesamples/android-$i
     32 
     33 result=$(curl -o /dev/null --silent --head --write-out '%{http_code}' "$URL")
     34 #echo "$result $URL"
     35 
     36 ##checking to see if the repo exists
     37 if [ "$result" != "200" ]; then
     38    echo "Cannot access repo for $i, it may not exist yet"
     39 else
     40    echo "Updating repo for $i"
     41 
     42 git clone $URL.git
     43 ##check to make sure it worked and the folder is there
     44 if [ -d "android-$i" ]; then
     45    rsync -az --delete --exclude '*.git' ../prebuilts/gradle/$i/ ./android-$i/
     46 
     47    cd ./android-$i/
     48 
     49    git config user.name "google-automerger"
     50    git config user.email automerger@google.com
     51 
     52    git add .
     53    git status
     54    git commit -m "Auto-update"
     55 
     56    git remote set-url origin "https://$TOKEN@github.com/googlesamples/android-$i.git"
     57    git push origin master
     58 
     59   cd ..
     60 else
     61    "Something went wrong when cloning $i - result directory does not exist."
     62 fi
     63 
     64 fi
     65 done
     66 
     67 ##cleanup
     68 cd ..
     69 rm -rf ./github-temp
     70