From d7eecaf827348ef51828391aa42807c15911adce Mon Sep 17 00:00:00 2001 From: Anupama Tuli Date: Tue, 5 Nov 2019 00:55:51 -0800 Subject: [PATCH 1/8] Update bikes.yml by adding a new step that updates the user's branch name such that a valid namespace can be created using that. This also needs an update to the existing add-review-url custom action. There is a new input that is passed in to this action to construct the url which contains the valid child namespace. Note: there is another update needed such that we call the version2 of the custom github action: add-review-url@Releases/v2 --- .github/workflows/bikes.yml | 26 +++++++++++++++++--------- actions/add-review-url/action.yml | 5 ++++- actions/add-review-url/lib/index.js | 2 +- actions/add-review-url/src/index.ts | 2 +- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml index b979050cd..d60fefc6a 100644 --- a/.github/workflows/bikes.yml +++ b/.github/workflows/bikes.yml @@ -13,7 +13,14 @@ jobs: steps: - uses: actions/checkout@master - + + - name: Create valid child namespace name + id: replace + run: | + branch=$GITHUB_HEAD_REF + branch=$(echo ${branch//[!0-9a-zA-Z]/-} | tr '[:upper:]' '[:lower:]' | sed '/^[-]/ s/./n/' | sed '/[-]$/ s/-$/n/') + echo ::set-output name=valid_child_namespace::$branch + - uses: azure/container-actions/docker-login@master with: login-server: ${{ secrets.CONTAINER_REGISTRY }} @@ -32,11 +39,11 @@ jobs: - name: Create child namespaces and add Dev Spaces labels run: | - if [ -n "$(kubectl get namespace $GITHUB_HEAD_REF --ignore-not-found -o name)" ]; then exit 0; fi - kubectl create namespace $GITHUB_HEAD_REF - kubectl label namespace $GITHUB_HEAD_REF azds.io/parent-space=${{ secrets.MASTER_SPACE }} - kubectl label namespace $GITHUB_HEAD_REF azds.io/space=true - kubectl label namespace $GITHUB_HEAD_REF azds.io/pull-request-space=true + if [ -n "$(kubectl get namespace ${{steps.replace.outputs.valid_child_namespace}} --ignore-not-found -o name)" ]; then exit 0; fi + kubectl create namespace ${{steps.replace.outputs.valid_child_namespace}} + kubectl label namespace ${{steps.replace.outputs.valid_child_namespace}} azds.io/parent-space=${{ secrets.MASTER_SPACE }} + kubectl label namespace ${{steps.replace.outputs.valid_child_namespace}} azds.io/space=true + kubectl label namespace ${{steps.replace.outputs.valid_child_namespace}} azds.io/pull-request-space=true - uses: azure/k8s-actions/k8s-create-secret@master with: @@ -49,12 +56,13 @@ jobs: - name: Helm Install PR run: | helm init --upgrade --wait - helm upgrade --install --namespace $GITHUB_HEAD_REF bikesharing-$GITHUB_HEAD_REF samples/BikeSharingApp/Bikes/charts/bikes \ + helm upgrade --install --namespace ${{steps.replace.outputs.valid_child_namespace}} bikesharing-${{steps.replace.outputs.valid_child_namespace}} samples/BikeSharingApp/Bikes/charts/bikes \ --set image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes \ --set image.tag=$GITHUB_SHA \ --set imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }} - - uses: azure/dev-spaces/actions/add-review-url@Releases/v1 + - uses: azure/dev-spaces/actions/add-review-url@Releases/v2 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - host: ${{ secrets.HOST }} \ No newline at end of file + host: ${{ secrets.HOST }} + child-namespace: ${{steps.replace.outputs.valid_child_namespace}} \ No newline at end of file diff --git a/actions/add-review-url/action.yml b/actions/add-review-url/action.yml index 37df34a10..b1afc9ad8 100644 --- a/actions/add-review-url/action.yml +++ b/actions/add-review-url/action.yml @@ -7,7 +7,10 @@ inputs: required: true host: # Complete host. description: "Complete host. This expands to: [rootSpace.]webfrontend...azds.io. For more information see https://aka.ms/devspaces/routing" - required: true + required: true + child-namespace: # Child Namespace. + description: "This is the child namespace name passed in from the workflow to construct the uri." + required: true runs: using: 'node12' main: 'lib/index.js' \ No newline at end of file diff --git a/actions/add-review-url/lib/index.js b/actions/add-review-url/lib/index.js index 3e0134e52..657d5e32a 100644 --- a/actions/add-review-url/lib/index.js +++ b/actions/add-review-url/lib/index.js @@ -28,7 +28,7 @@ function run() { const addComment = new AddReviewUrl_1.default(); try { const host = core.getInput('host'); - let headref = process.env.GITHUB_HEAD_REF || ''; + let headref = core.getInput('child-namespace') || ''; const comment = `You can see a private version of the changes made in this pull request here:\nhttp://${headref}.s.${host}/`; yield addComment.addComment(comment); } diff --git a/actions/add-review-url/src/index.ts b/actions/add-review-url/src/index.ts index ab4308a3a..c6cc3732f 100644 --- a/actions/add-review-url/src/index.ts +++ b/actions/add-review-url/src/index.ts @@ -7,7 +7,7 @@ async function run() { const addComment = new AddComment(); try { const host = core.getInput('host'); - let headref = process.env.GITHUB_HEAD_REF || ''; + let headref = core.getInput('child-namespace') || ''; const comment = `You can see a private version of the changes made in this pull request here:\nhttp://${headref}.s.${host}/`; await addComment.addComment(comment); }catch (error) { From 479903f087d0af0068348fcc305e038a99d0cf50 Mon Sep 17 00:00:00 2001 From: Anupama Tuli Date: Tue, 5 Nov 2019 15:53:12 -0800 Subject: [PATCH 2/8] Address Pr feedback. Update the length to 41 as allowed by namespace name specs and Release spec for the Helm install command in bikes.yml. Update some of the variable names. Tested E2E. This will need a Release/v2 branch which will contain node_modules as well. --- .github/workflows/bikes.yml | 37 +++++++++++++---------------- actions/add-review-url/action.yml | 2 +- actions/add-review-url/lib/index.js | 2 +- actions/add-review-url/src/index.ts | 2 +- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml index 7f6679c11..df46bf94f 100644 --- a/.github/workflows/bikes.yml +++ b/.github/workflows/bikes.yml @@ -12,19 +12,9 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@master + - uses: actions/checkout@master - - name: Create valid child namespace name - id: replace - run: | - branch=$GITHUB_HEAD_REF - branch=$(echo ${branch//[!0-9a-zA-Z]/-} | tr '[:upper:]' '[:lower:]' | sed '/^[-]/ s/./n/' | sed '/[-]$/ s/-$/n/') - echo ::set-output name=valid_child_namespace::$branch - - - uses: azure/container-actions/docker-login@master - - uses: azure/docker-login@releases/v1 - with: login-server: ${{ secrets.CONTAINER_REGISTRY }} username: ${{ secrets.REGISTRY_USERNAME }} @@ -39,18 +29,25 @@ jobs: creds: '${{ secrets.AZURE_CREDENTIALS }}' cluster-name: ${{ secrets.CLUSTER_NAME }} resource-group: ${{ secrets.RESOURCE_GROUP }} - + + - name: Create valid child namespace name + id: generate-child-space-name + run: | + branch=${GITHUB_HEAD_REF::41} + branch=$(echo ${branch//[!0-9a-zA-Z]/-} | tr '[:upper:]' '[:lower:]' | sed -e 's/^-/z/' -e 's/-$/z/') + echo ::set-output name=valid_child_space_name::$branch + - name: Create child namespaces and add Dev Spaces labels run: | - if [ -n "$(kubectl get namespace ${{steps.replace.outputs.valid_child_namespace}} --ignore-not-found -o name)" ]; then exit 0; fi - kubectl create namespace ${{steps.replace.outputs.valid_child_namespace}} - kubectl label namespace ${{steps.replace.outputs.valid_child_namespace}} azds.io/parent-space=${{ secrets.MASTER_SPACE }} - kubectl label namespace ${{steps.replace.outputs.valid_child_namespace}} azds.io/space=true - kubectl label namespace ${{steps.replace.outputs.valid_child_namespace}} azds.io/pull-request-space=true + if [ -n "$(kubectl get namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} --ignore-not-found -o name)" ]; then exit 0; fi + kubectl create namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} + kubectl label namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} azds.io/parent-space=${{ secrets.MASTER_SPACE }} + kubectl label namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} azds.io/space=true + kubectl label namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} azds.io/pull-request-space=true - uses: azure/k8s-actions/k8s-create-secret@master with: - namespace: ${{ github.head_ref }} + namespace: ${{ steps.generate-child-space-name.outputs.valid_child_space_name }} container-registry-url: ${{ secrets.CONTAINER_REGISTRY }} container-registry-username: ${{ secrets.REGISTRY_USERNAME }} container-registry-password: ${{ secrets.REGISTRY_PASSWORD }} @@ -59,7 +56,7 @@ jobs: - name: Helm Install PR run: | helm init --upgrade --wait - helm upgrade --install --namespace ${{steps.replace.outputs.valid_child_namespace}} bikesharing-${{steps.replace.outputs.valid_child_namespace}} samples/BikeSharingApp/Bikes/charts/bikes \ + helm upgrade --install --namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} bikesharing-${{steps.generate-child-space-name.outputs.valid_child_space_name}} samples/BikeSharingApp/Bikes/charts/bikes \ --set image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes \ --set image.tag=$GITHUB_SHA \ --set imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }} @@ -68,4 +65,4 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} host: ${{ secrets.HOST }} - child-namespace: ${{steps.replace.outputs.valid_child_namespace}} \ No newline at end of file + child-space: ${{steps.generate-child-space-name.outputs.valid_child_space_name}} \ No newline at end of file diff --git a/actions/add-review-url/action.yml b/actions/add-review-url/action.yml index b1afc9ad8..9ed7d5616 100644 --- a/actions/add-review-url/action.yml +++ b/actions/add-review-url/action.yml @@ -8,7 +8,7 @@ inputs: host: # Complete host. description: "Complete host. This expands to: [rootSpace.]webfrontend...azds.io. For more information see https://aka.ms/devspaces/routing" required: true - child-namespace: # Child Namespace. + child-space: # Child space. description: "This is the child namespace name passed in from the workflow to construct the uri." required: true runs: diff --git a/actions/add-review-url/lib/index.js b/actions/add-review-url/lib/index.js index 657d5e32a..0d93a28f9 100644 --- a/actions/add-review-url/lib/index.js +++ b/actions/add-review-url/lib/index.js @@ -28,7 +28,7 @@ function run() { const addComment = new AddReviewUrl_1.default(); try { const host = core.getInput('host'); - let headref = core.getInput('child-namespace') || ''; + let headref = core.getInput('child-space') || ''; const comment = `You can see a private version of the changes made in this pull request here:\nhttp://${headref}.s.${host}/`; yield addComment.addComment(comment); } diff --git a/actions/add-review-url/src/index.ts b/actions/add-review-url/src/index.ts index c6cc3732f..8b71c221d 100644 --- a/actions/add-review-url/src/index.ts +++ b/actions/add-review-url/src/index.ts @@ -7,7 +7,7 @@ async function run() { const addComment = new AddComment(); try { const host = core.getInput('host'); - let headref = core.getInput('child-namespace') || ''; + let headref = core.getInput('child-space') || ''; const comment = `You can see a private version of the changes made in this pull request here:\nhttp://${headref}.s.${host}/`; await addComment.addComment(comment); }catch (error) { From 01b23a8df76c3ee752987dd2b344db66ea843479 Mon Sep 17 00:00:00 2001 From: Anupama Tuli Date: Tue, 5 Nov 2019 17:15:03 -0800 Subject: [PATCH 3/8] Update the output parameter name --- .github/workflows/bikes.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml index df46bf94f..824ca5178 100644 --- a/.github/workflows/bikes.yml +++ b/.github/workflows/bikes.yml @@ -35,19 +35,19 @@ jobs: run: | branch=${GITHUB_HEAD_REF::41} branch=$(echo ${branch//[!0-9a-zA-Z]/-} | tr '[:upper:]' '[:lower:]' | sed -e 's/^-/z/' -e 's/-$/z/') - echo ::set-output name=valid_child_space_name::$branch + echo ::set-output name=result::$branch - name: Create child namespaces and add Dev Spaces labels run: | - if [ -n "$(kubectl get namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} --ignore-not-found -o name)" ]; then exit 0; fi - kubectl create namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} - kubectl label namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} azds.io/parent-space=${{ secrets.MASTER_SPACE }} - kubectl label namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} azds.io/space=true - kubectl label namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} azds.io/pull-request-space=true + if [ -n "$(kubectl get namespace ${{steps.generate-child-space-name.outputs.result}} --ignore-not-found -o name)" ]; then exit 0; fi + kubectl create namespace ${{steps.generate-child-space-name.outputs.result}} + kubectl label namespace ${{steps.generate-child-space-name.outputs.result}} azds.io/parent-space=${{ secrets.MASTER_SPACE }} + kubectl label namespace ${{steps.generate-child-space-name.outputs.result}} azds.io/space=true + kubectl label namespace ${{steps.generate-child-space-name.outputs.result}} azds.io/pull-request-space=true - uses: azure/k8s-actions/k8s-create-secret@master with: - namespace: ${{ steps.generate-child-space-name.outputs.valid_child_space_name }} + namespace: ${{ steps.generate-child-space-name.outputs.result }} container-registry-url: ${{ secrets.CONTAINER_REGISTRY }} container-registry-username: ${{ secrets.REGISTRY_USERNAME }} container-registry-password: ${{ secrets.REGISTRY_PASSWORD }} @@ -56,7 +56,7 @@ jobs: - name: Helm Install PR run: | helm init --upgrade --wait - helm upgrade --install --namespace ${{steps.generate-child-space-name.outputs.valid_child_space_name}} bikesharing-${{steps.generate-child-space-name.outputs.valid_child_space_name}} samples/BikeSharingApp/Bikes/charts/bikes \ + helm upgrade --install --namespace ${{steps.generate-child-space-name.outputs.result}} bikesharing-${{steps.generate-child-space-name.outputs.result}} samples/BikeSharingApp/Bikes/charts/bikes \ --set image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes \ --set image.tag=$GITHUB_SHA \ --set imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }} @@ -65,4 +65,4 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} host: ${{ secrets.HOST }} - child-space: ${{steps.generate-child-space-name.outputs.valid_child_space_name}} \ No newline at end of file + child-space: ${{steps.generate-child-space-name.outputs.result}} \ No newline at end of file From 7cf7b541326b2206feb316ccd32510459f47cf0d Mon Sep 17 00:00:00 2001 From: Anupama Tuli Date: Thu, 7 Nov 2019 09:08:12 -0800 Subject: [PATCH 4/8] Add optional parameter: protocol for the custom github action: add-review-url such that the user specifies http vs https as needed. If not specified the protocol defaults to http. Update bikes.yml to add a step for installing helm for client if client and server version does not match. Add a step to create a valid release-name based on spec for the same by formatting the GITHUB_HEAD_REF environment variable. --- .github/workflows/bikes.yml | 45 ++++++++++++++++++++++++----- actions/add-review-url/action.yml | 3 ++ actions/add-review-url/lib/index.js | 3 +- actions/add-review-url/src/index.ts | 5 ++-- 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml index 824ca5178..2e4f6586f 100644 --- a/.github/workflows/bikes.yml +++ b/.github/workflows/bikes.yml @@ -10,8 +10,7 @@ on: jobs: build: runs-on: ubuntu-latest - steps: - + steps: - uses: actions/checkout@master - uses: azure/docker-login@releases/v1 @@ -33,7 +32,7 @@ jobs: - name: Create valid child namespace name id: generate-child-space-name run: | - branch=${GITHUB_HEAD_REF::41} + branch=${GITHUB_HEAD_REF::63} branch=$(echo ${branch//[!0-9a-zA-Z]/-} | tr '[:upper:]' '[:lower:]' | sed -e 's/^-/z/' -e 's/-$/z/') echo ::set-output name=result::$branch @@ -52,11 +51,40 @@ jobs: container-registry-username: ${{ secrets.REGISTRY_USERNAME }} container-registry-password: ${{ secrets.REGISTRY_PASSWORD }} secret-name: ${{ secrets.IMAGE_PULL_SECRET }} - - - name: Helm Install PR + + - name: Create valid release-name + id: generate-release-name run: | - helm init --upgrade --wait - helm upgrade --install --namespace ${{steps.generate-child-space-name.outputs.result}} bikesharing-${{steps.generate-child-space-name.outputs.result}} samples/BikeSharingApp/Bikes/charts/bikes \ + release=${bikesharing-$GITHUB_HEAD_REF} + release=${release::53} + release=$(echo ${release//[!0-9a-zA-Z]/-} | tr '[:upper:]' '[:lower:]' | sed -e 's/^-/z/' -e 's/-$/z/') + echo ::set-output name=result::$release + + - name: Install Helm for client + id: install-helm-client + run: | + clientversion=$(echo $(helm version --client --short) | sed -n 's/.*Client: \(.*\)+.*/\1/p') + serverversion=$(echo $(helm version --server --short) | sed -n 's/.*Server: \(.*\)+.*/\1/p') + if [[ ! -n "$serverversion" ]]; + then + echo "Please install Helm on the server!" 1>&2 + exit 64 + elif [[ "$clientversion" == "$serverversion" ]]; + then + echo "Versions are equal" + echo ::set-output name=result:: + else + mkdir prflow + export DESIRED_VERSION=$serverversion export HELM_INSTALL_DIR=./prflow + curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh + chmod 700 get_helm.sh + ./get_helm.sh + echo ::set-output name=result::./prflow/ + fi + + - name: Helm Upgrade PR + run: | + ${{steps.install-helm-client.outputs.result}}helm upgrade --install --namespace ${{steps.generate-child-space-name.outputs.result}} ${{steps.generate-release-name.outputs.result}} samples/BikeSharingApp/Bikes/charts/bikes \ --set image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes \ --set image.tag=$GITHUB_SHA \ --set imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }} @@ -65,4 +93,5 @@ jobs: with: repo-token: ${{ secrets.GITHUB_TOKEN }} host: ${{ secrets.HOST }} - child-space: ${{steps.generate-child-space-name.outputs.result}} \ No newline at end of file + child-space: ${{steps.generate-child-space-name.outputs.result}} + protocol: 'http' \ No newline at end of file diff --git a/actions/add-review-url/action.yml b/actions/add-review-url/action.yml index 9ed7d5616..7ebf28392 100644 --- a/actions/add-review-url/action.yml +++ b/actions/add-review-url/action.yml @@ -11,6 +11,9 @@ inputs: child-space: # Child space. description: "This is the child namespace name passed in from the workflow to construct the uri." required: true + protocol: # This is an optional parameter that the user can specify (http vs https) + description: "This is an optional parameter that the user can specify: example values - http or https" + required: false runs: using: 'node12' main: 'lib/index.js' \ No newline at end of file diff --git a/actions/add-review-url/lib/index.js b/actions/add-review-url/lib/index.js index 0d93a28f9..c8f27abaa 100644 --- a/actions/add-review-url/lib/index.js +++ b/actions/add-review-url/lib/index.js @@ -29,7 +29,8 @@ function run() { try { const host = core.getInput('host'); let headref = core.getInput('child-space') || ''; - const comment = `You can see a private version of the changes made in this pull request here:\nhttp://${headref}.s.${host}/`; + let protocol = core.getInput('protocol') || 'http'; + const comment = `You can see a private version of the changes made in this pull request here:\n${protocol}://${headref}.s.${host}/`; yield addComment.addComment(comment); } catch (error) { diff --git a/actions/add-review-url/src/index.ts b/actions/add-review-url/src/index.ts index 8b71c221d..866aa4936 100644 --- a/actions/add-review-url/src/index.ts +++ b/actions/add-review-url/src/index.ts @@ -7,8 +7,9 @@ async function run() { const addComment = new AddComment(); try { const host = core.getInput('host'); - let headref = core.getInput('child-space') || ''; - const comment = `You can see a private version of the changes made in this pull request here:\nhttp://${headref}.s.${host}/`; + let headref = core.getInput('child-space') || ''; + let protocol = core.getInput('protocol') || 'http'; + const comment = `You can see a private version of the changes made in this pull request here:\n${protocol}://${headref}.s.${host}/`; await addComment.addComment(comment); }catch (error) { core.setFailed(error.message); From 8ab742499888fb7b074737b1d3abf00118f3bdc1 Mon Sep 17 00:00:00 2001 From: Anupama Tuli Date: Thu, 7 Nov 2019 15:06:30 -0800 Subject: [PATCH 5/8] Addressing PR feedback. Code clean-up. Using a temporary directory for installing Helm into in case the client version does not match the server version. --- .github/workflows/bikes.yml | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml index 2e4f6586f..4170b1a38 100644 --- a/.github/workflows/bikes.yml +++ b/.github/workflows/bikes.yml @@ -55,7 +55,7 @@ jobs: - name: Create valid release-name id: generate-release-name run: | - release=${bikesharing-$GITHUB_HEAD_REF} + release=bikesharing-$GITHUB_HEAD_REF release=${release::53} release=$(echo ${release//[!0-9a-zA-Z]/-} | tr '[:upper:]' '[:lower:]' | sed -e 's/^-/z/' -e 's/-$/z/') echo ::set-output name=result::$release @@ -63,28 +63,29 @@ jobs: - name: Install Helm for client id: install-helm-client run: | - clientversion=$(echo $(helm version --client --short) | sed -n 's/.*Client: \(.*\)+.*/\1/p') - serverversion=$(echo $(helm version --server --short) | sed -n 's/.*Server: \(.*\)+.*/\1/p') - if [[ ! -n "$serverversion" ]]; - then + set -e + clientversion=$(helm version --client --short | cut -d' ' -f2 | cut -d'+' -f1) + serverversion=$(helm version --server --short | cut -d' ' -f2 | cut -d'+' -f1) + if [ ! -n "$serverversion" ]; then echo "Please install Helm on the server!" 1>&2 - exit 64 - elif [[ "$clientversion" == "$serverversion" ]]; - then - echo "Versions are equal" + exit 1 + elif [ "$clientversion" == "$serverversion" ]; then + echo The client and server Helm Versions are equal echo ::set-output name=result:: else - mkdir prflow - export DESIRED_VERSION=$serverversion export HELM_INSTALL_DIR=./prflow + tmp_dir=$(mktemp -d) + export DESIRED_VERSION=$serverversion HELM_INSTALL_DIR=$tmp_dir curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh chmod 700 get_helm.sh ./get_helm.sh - echo ::set-output name=result::./prflow/ + echo ::set-output name=result::$tmp_dir/ fi - name: Helm Upgrade PR run: | - ${{steps.install-helm-client.outputs.result}}helm upgrade --install --namespace ${{steps.generate-child-space-name.outputs.result}} ${{steps.generate-release-name.outputs.result}} samples/BikeSharingApp/Bikes/charts/bikes \ + ${{steps.install-helm-client.outputs.result}}helm upgrade \ + --install ${{steps.generate-release-name.outputs.result}} samples/BikeSharingApp/Bikes/charts/bikes \ + --namespace ${{steps.generate-child-space-name.outputs.result}} \ --set image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes \ --set image.tag=$GITHUB_SHA \ --set imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }} From 41af60fe5c1c1c91f787b33331f4ed955baf81e4 Mon Sep 17 00:00:00 2001 From: Anupama Tuli Date: Fri, 8 Nov 2019 11:37:57 -0800 Subject: [PATCH 6/8] Update the step:Create 'child namespaces and add Dev Spaces labels' and clean-up and make it faster by updating the command-kubectl label namespace --- .github/workflows/bikes.yml | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml index 4170b1a38..f31a3c05d 100644 --- a/.github/workflows/bikes.yml +++ b/.github/workflows/bikes.yml @@ -39,10 +39,11 @@ jobs: - name: Create child namespaces and add Dev Spaces labels run: | if [ -n "$(kubectl get namespace ${{steps.generate-child-space-name.outputs.result}} --ignore-not-found -o name)" ]; then exit 0; fi - kubectl create namespace ${{steps.generate-child-space-name.outputs.result}} - kubectl label namespace ${{steps.generate-child-space-name.outputs.result}} azds.io/parent-space=${{ secrets.MASTER_SPACE }} - kubectl label namespace ${{steps.generate-child-space-name.outputs.result}} azds.io/space=true - kubectl label namespace ${{steps.generate-child-space-name.outputs.result}} azds.io/pull-request-space=true + kubectl create namespace ${{steps.generate-child-space-name.outputs.result}} \ + kubectl label namespace ${{steps.generate-child-space-name.outputs.result}} \ + azds.io/parent-space=${{ secrets.MASTER_SPACE }} \ + azds.io/space=true \ + azds.io/pull-request-space=true - uses: azure/k8s-actions/k8s-create-secret@master with: @@ -78,12 +79,12 @@ jobs: curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh chmod 700 get_helm.sh ./get_helm.sh - echo ::set-output name=result::$tmp_dir/ + echo ::set-output name=install_location::$tmp_dir/ fi - name: Helm Upgrade PR run: | - ${{steps.install-helm-client.outputs.result}}helm upgrade \ + ${{steps.install-helm-client.outputs.install_location}}helm upgrade \ --install ${{steps.generate-release-name.outputs.result}} samples/BikeSharingApp/Bikes/charts/bikes \ --namespace ${{steps.generate-child-space-name.outputs.result}} \ --set image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes \ From b7f84e1c76afcf0beb163beb1e7d18eb595f97e2 Mon Sep 17 00:00:00 2001 From: Anupama Tuli Date: Fri, 8 Nov 2019 13:24:46 -0800 Subject: [PATCH 7/8] Update the name of the output for the step: Install Helm for client --- .github/workflows/bikes.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml index f31a3c05d..6aa132ebe 100644 --- a/.github/workflows/bikes.yml +++ b/.github/workflows/bikes.yml @@ -13,7 +13,7 @@ jobs: steps: - uses: actions/checkout@master - - uses: azure/docker-login@releases/v1 + - uses: azure/docker-login@v1 with: login-server: ${{ secrets.CONTAINER_REGISTRY }} username: ${{ secrets.REGISTRY_USERNAME }} @@ -72,19 +72,19 @@ jobs: exit 1 elif [ "$clientversion" == "$serverversion" ]; then echo The client and server Helm Versions are equal - echo ::set-output name=result:: + echo ::set-output name=helm::helm else tmp_dir=$(mktemp -d) export DESIRED_VERSION=$serverversion HELM_INSTALL_DIR=$tmp_dir curl https://raw.githubusercontent.com/helm/helm/master/scripts/get > get_helm.sh chmod 700 get_helm.sh ./get_helm.sh - echo ::set-output name=install_location::$tmp_dir/ + echo ::set-output name=helm::$tmp_dir/helm fi - name: Helm Upgrade PR run: | - ${{steps.install-helm-client.outputs.install_location}}helm upgrade \ + ${{steps.install-helm-client.outputs.helm}} upgrade \ --install ${{steps.generate-release-name.outputs.result}} samples/BikeSharingApp/Bikes/charts/bikes \ --namespace ${{steps.generate-child-space-name.outputs.result}} \ --set image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes \ From a4c40877d53ec0d44e40de303588b16b9834ebfa Mon Sep 17 00:00:00 2001 From: Anupama Tuli Date: Fri, 8 Nov 2019 13:36:07 -0800 Subject: [PATCH 8/8] Indenting the commands post kubectl label namespace command in the step: Create child namespaces and add Dev Spaces labels --- .github/workflows/bikes.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml index 6aa132ebe..1887b9062 100644 --- a/.github/workflows/bikes.yml +++ b/.github/workflows/bikes.yml @@ -41,9 +41,9 @@ jobs: if [ -n "$(kubectl get namespace ${{steps.generate-child-space-name.outputs.result}} --ignore-not-found -o name)" ]; then exit 0; fi kubectl create namespace ${{steps.generate-child-space-name.outputs.result}} \ kubectl label namespace ${{steps.generate-child-space-name.outputs.result}} \ - azds.io/parent-space=${{ secrets.MASTER_SPACE }} \ - azds.io/space=true \ - azds.io/pull-request-space=true + azds.io/parent-space=${{ secrets.MASTER_SPACE }} \ + azds.io/space=true \ + azds.io/pull-request-space=true - uses: azure/k8s-actions/k8s-create-secret@master with: