github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/service/runtime/cells/go/entrypoint.sh (about) 1 #!/bin/dumb-init /bin/sh 2 3 set -x 4 set -e 5 6 git version 7 8 mkdir /app 9 cd app 10 11 URL=$1 12 13 REF="" 14 if [[ $URL == *"@"* ]]; then 15 # Save the ref 16 REF=$(echo $URL | cut -d@ -f 2-) 17 # URL should not contain the ref 18 URL=$(echo $URL | cut -d@ -f -1) 19 fi 20 21 if [[ $REF == "latest" ]]; then 22 REF="master" 23 fi 24 25 REPO=$(echo $URL | cut -d/ -f -3) 26 P=$(echo $URL | cut -d/ -f 4-) 27 28 echo "Repo is $REPO" 29 echo "Path is $P" 30 echo "Ref is $REF" 31 32 33 if [[ -z "$GIT_CREDENTIALS" ]]; then 34 echo "Cloning $REPO" 35 CLONE_URL=https://$REPO 36 else 37 echo "Cloning $REPO with credentials" 38 CLONE_URL=https://$GIT_CREDENTIALS@$REPO 39 fi 40 41 # clone the repo 42 git clone $CLONE_URL --branch $REF --single-branch . 43 if [ $? -eq 0 ]; then 44 echo "Successfully cloned branch" 45 else 46 # Clone the full repo if the REF was not a branch. 47 # In case of a commit REF we will git reset later. 48 git clone https://$REPO . 49 fi 50 51 # Try to check out commit and do not care if it fails 52 git reset --hard $REF 53 54 cd $P 55 56 # find the entrypoint using the util 57 ENTRYPOINT=$(entrypoint) 58 59 # run the source 60 echo "Running service" 61 go run $ENTRYPOINT