From 50648d2443b8ed289d45e436bf1dfc6b998ad1a8 Mon Sep 17 00:00:00 2001 From: Yvonne Radsmikham Date: Tue, 29 Jan 2019 11:12:13 -0800 Subject: [PATCH 1/3] Add build.sh --- gitops/azure-devops/build.sh | 58 ++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 gitops/azure-devops/build.sh diff --git a/gitops/azure-devops/build.sh b/gitops/azure-devops/build.sh new file mode 100644 index 0000000..cfaa0be --- /dev/null +++ b/gitops/azure-devops/build.sh @@ -0,0 +1,58 @@ +cd /home/vsts/work/1/s/ + +# Store the ouput of `curl -s https://api.github.com/repos/Microsoft/fabrikate/tags` +# If the release number is not provided, then download the latest +if [ -z "$VERSION" ] +then + VERSIONS=$(curl -s https://api.github.com/repos/Microsoft/fabrikate/tags) + LATEST_RELEASE=$(echo $VERSIONS | grep "name" | head -1) + LATEST_VERSION=`echo "$LATEST_RELEASE" | cut -d'"' -f 4` +else + echo "Fabrikate Version: $VERSION" +fi + +echo "Downloading Fabrikate..." +echo "Latest Fabrikate Version: $LATEST_VERSION" +#wget "https://github.com/Microsoft/fabrikate/releases/download/0.1.2/fab-v0.1.2-linux-amd64.zip" +wget "https://github.com/Microsoft/fabrikate/releases/download/$LATEST_VERSION/fab-v$LATEST_VERSION-linux-amd64.zip" +#unzip fab-v0.1.2-linux-amd64.zip -d fab +unzip fab-v$LATEST_VERSION-linux-amd64.zip -d fab +export PATH=$PATH:/home/vsts/work/1/s/fab +fab install + +#git clone https://github.com/Microsoft/fabrikate +#cd fabrikate/examples/getting-started +fab generate prod +echo "FAB GENERATE PROD COMPLETED" +ls -a + +cd /home/vsts/work/1/s/ +echo "GIT CLONE" +git clone https://github.com/yradsmikham/walmart-k8s.git +cd walmart-k8s + +echo "GIT CHECKOUT" +git checkout master +echo "GIT STATUS" +git status +echo "Copy yaml files to repo directory..." +rm -rf prod/ +cp -r /home/vsts/work/1/s/generated/* . +ls /home/vsts/work/1/s/walmart-k8s +echo "GIT ADD" +git add * + +#Set git identity +git config user.email "admin@azuredevops.com" +git config user.name "Automated Account" + +echo "GIT COMMIT" +git commit -m "Updated k8s manifest files" +echo "GIT STATUS" +git status +echo "GIT PULL" +git pull +echo "GIT PUSH" +git push https://$ACCESS_TOKEN@github.com/yradsmikham/walmart-k8s.git +echo "GIT STATUS" +git status From b6b1dd97074d0a073ec997f980470461b2628ad4 Mon Sep 17 00:00:00 2001 From: Yvonne Radsmikham Date: Tue, 29 Jan 2019 11:13:28 -0800 Subject: [PATCH 2/3] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 0a5452b..d7e282e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ terraform.tfstate terraform.tfstate.backup translations istio-1.0.4 +.DS_Store From e0f0c15e9bf9a7ad909ac894b365250acc6d2cff Mon Sep 17 00:00:00 2001 From: Yvonne Radsmikham Date: Tue, 29 Jan 2019 13:02:49 -0800 Subject: [PATCH 3/3] Parameterized AKS Manifest Repo --- gitops/azure-devops/build.sh | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gitops/azure-devops/build.sh b/gitops/azure-devops/build.sh index cfaa0be..0b67add 100644 --- a/gitops/azure-devops/build.sh +++ b/gitops/azure-devops/build.sh @@ -1,7 +1,6 @@ cd /home/vsts/work/1/s/ -# Store the ouput of `curl -s https://api.github.com/repos/Microsoft/fabrikate/tags` -# If the release number is not provided, then download the latest +# If the version number is not provided, then download the latest if [ -z "$VERSION" ] then VERSIONS=$(curl -s https://api.github.com/repos/Microsoft/fabrikate/tags) @@ -13,23 +12,25 @@ fi echo "Downloading Fabrikate..." echo "Latest Fabrikate Version: $LATEST_VERSION" -#wget "https://github.com/Microsoft/fabrikate/releases/download/0.1.2/fab-v0.1.2-linux-amd64.zip" wget "https://github.com/Microsoft/fabrikate/releases/download/$LATEST_VERSION/fab-v$LATEST_VERSION-linux-amd64.zip" -#unzip fab-v0.1.2-linux-amd64.zip -d fab unzip fab-v$LATEST_VERSION-linux-amd64.zip -d fab export PATH=$PATH:/home/vsts/work/1/s/fab fab install -#git clone https://github.com/Microsoft/fabrikate -#cd fabrikate/examples/getting-started fab generate prod echo "FAB GENERATE PROD COMPLETED" ls -a +# Git cd /home/vsts/work/1/s/ echo "GIT CLONE" -git clone https://github.com/yradsmikham/walmart-k8s.git -cd walmart-k8s +git clone https://github.com/$AKS_MANIFEST_REPO.git +repo_url=https://github.com/$AKS_MANIFEST_REPO.git +repo=${repo_url##*/} +echo "REPO:$repo" +repo_name=${repo%.*} +echo "REPO_NAME:$repo_name" +cd $repo_name echo "GIT CHECKOUT" git checkout master @@ -38,11 +39,11 @@ git status echo "Copy yaml files to repo directory..." rm -rf prod/ cp -r /home/vsts/work/1/s/generated/* . -ls /home/vsts/work/1/s/walmart-k8s +ls /home/vsts/work/1/s/$repo_name echo "GIT ADD" git add * -#Set git identity +# Set git identity git config user.email "admin@azuredevops.com" git config user.name "Automated Account" @@ -53,6 +54,6 @@ git status echo "GIT PULL" git pull echo "GIT PUSH" -git push https://$ACCESS_TOKEN@github.com/yradsmikham/walmart-k8s.git +git push https://$ACCESS_TOKEN@github.com/$AKS_MANIFEST_REPO.git echo "GIT STATUS" git status