From 3fd21cfa68b2e65e82826b15112123c37b568837 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 2 Oct 2019 15:12:59 -0700 Subject: [PATCH 1/3] Add bikes pr workflow and biksharing workflow for GitHub Actions --- .github/workflows/bikes.yml | 51 +++++++++++++++++++++++++++ .github/workflows/bikesharing.yml | 57 +++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 .github/workflows/bikes.yml create mode 100644 .github/workflows/bikesharing.yml diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml new file mode 100644 index 000000000..91812a302 --- /dev/null +++ b/.github/workflows/bikes.yml @@ -0,0 +1,51 @@ +name: PRFlow Bikes + +on: + pull_request: + branches: + - master + paths: + - samples/BikeSharingApp/Bikes/* + +jobs: + build: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@master + + - uses: azure/container-actions/docker-login@master + with: + login-server: ${{ secrets.CONTAINER_REGISTRY }} + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - run: | + docker build samples/BikeSharingApp/Bikes/ -t ${{ secrets.CONTAINER_REGISTRY }}/bikes:$GITHUB_SHA + docker push ${{ secrets.CONTAINER_REGISTRY }}/bikes:$GITHUB_SHA + + - uses: azure/k8s-actions/aks-set-context@master + with: + creds: '${{ secrets.AZURE_CREDENTIALS }}' + cluster-name: ${{ secrets.CLUSTER_NAME }} + resource-group: ${{ secrets.RESOURCE_GROUP }} + + - 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.PARENT_SPACE }} + kubectl label namespace $GITHUB_HEAD_REF azds.io/space=true + + - uses: azure/k8s-actions/k8s-create-secret@master + with: + namespace: ${{ github.head_ref }} + container-registry-url: ${{ secrets.CONTAINER_REGISTRY }} + container-registry-username: ${{ secrets.REGISTRY_USERNAME }} + container-registry-password: ${{ secrets.REGISTRY_PASSWORD }} + secret-name: ${{ secrets.IMAGE_PULL_SECRET }} + + - name: Helm Instal PR + run: | + helm upgrade --install --namespace $GITHUB_HEAD_REF bikesharing-$GITHUB_HEAD_REF samples/BikeSharingApp/Bikes/charts/bikes --set "image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes,image.tag=$GITHUB_SHA,imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }},ingress.hosts[0]=$GITHUB_HEAD_REF.s.${{ secrets.PARENT_SPACE }}.bikesharing.${{ secrets.HOST_SUFFIX }},ingress.annotations.\"kubernetes\\.io/ingress\\.class\"=traefik-azds" + diff --git a/.github/workflows/bikesharing.yml b/.github/workflows/bikesharing.yml new file mode 100644 index 000000000..b94805a88 --- /dev/null +++ b/.github/workflows/bikesharing.yml @@ -0,0 +1,57 @@ +name: Master + +on: + push: + branches: + - master + paths: + - samples/BikeSharingApp/** + - "!**/*.md" + +jobs: + build: + runs-on: ubuntu-latest + steps: + + - uses: actions/checkout@master + + - uses: azure/container-actions/docker-login@master + with: + login-server: '${{ secrets.CONTAINER_REGISTRY }}' + username: '${{ secrets.REGISTRY_USERNAME }}' + password: '${{ secrets.REGISTRY_PASSWORD }}' + + - run: | + docker build samples/BikeSharingApp/Bikes/ -t ${{ secrets.CONTAINER_REGISTRY }}/bikes:$GITHUB_SHA + docker push ${{ secrets.CONTAINER_REGISTRY }}/bikes:$GITHUB_SHA + + docker build samples/BikeSharingApp/BikeSharingWeb/ -t ${{ secrets.CONTAINER_REGISTRY }}/bikesharingweb:$GITHUB_SHA + docker push ${{ secrets.CONTAINER_REGISTRY }}/bikesharingweb:$GITHUB_SHA + + docker build samples/BikeSharingApp/Billing/ -t ${{ secrets.CONTAINER_REGISTRY }}/billing:$GITHUB_SHA + docker push ${{ secrets.CONTAINER_REGISTRY }}/billing:$GITHUB_SHA + + docker build samples/BikeSharingApp/Gateway/ -t ${{ secrets.CONTAINER_REGISTRY }}/gateway:$GITHUB_SHA + docker push ${{ secrets.CONTAINER_REGISTRY }}/gateway:$GITHUB_SHA + + docker build samples/BikeSharingApp/Reservation/ -t ${{ secrets.CONTAINER_REGISTRY }}/reservation:$GITHUB_SHA + docker push ${{ secrets.CONTAINER_REGISTRY }}/reservation:$GITHUB_SHA + + docker build samples/BikeSharingApp/ReservationEngine/ -t ${{ secrets.CONTAINER_REGISTRY }}/reservationengine:$GITHUB_SHA + docker push ${{ secrets.CONTAINER_REGISTRY }}/reservationengine:$GITHUB_SHA + + docker build samples/BikeSharingApp/Users/ -t ${{ secrets.CONTAINER_REGISTRY }}/users:$GITHUB_SHA + docker push ${{ secrets.CONTAINER_REGISTRY }}/users:$GITHUB_SHA + + - uses: azure/k8s-actions/aks-set-context@master + with: + creds: '${{ secrets.AZURE_CREDENTIALS }}' + cluster-name: '${{ secrets.CLUSTER_NAME }}' + resource-group: '${{ secrets.RESOURCE_GROUP }}' + + - name: Helm Install Master + run: | + cd samples/BikeSharingApp/charts + helm init --client-only + helm dependency update + helm upgrade --install --namespace ${{ secrets.PARENT_SPACE }} bikesharing . --set "bikes.image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes, bikesharingweb.image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikesharingweb, billing.image.repository=${{ secrets.CONTAINER_REGISTRY }}/billing, gateway.image.repository=${{ secrets.CONTAINER_REGISTRY }}/gateway, reservation.image.repository=${{ secrets.CONTAINER_REGISTRY }}/reservation, reservationengine.image.repository=${{ secrets.CONTAINER_REGISTRY }}/reservationengine, users.image.repository=${{ secrets.CONTAINER_REGISTRY }}/users, image.tag=$GITHUB_SHA" From 685c6e4d6cc7cbec17a6294e3de9ee0052164afa Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 2 Oct 2019 15:27:09 -0700 Subject: [PATCH 2/3] Fix spelling on Action label --- .github/workflows/bikes.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml index 91812a302..56c9c2a4e 100644 --- a/.github/workflows/bikes.yml +++ b/.github/workflows/bikes.yml @@ -45,7 +45,7 @@ jobs: container-registry-password: ${{ secrets.REGISTRY_PASSWORD }} secret-name: ${{ secrets.IMAGE_PULL_SECRET }} - - name: Helm Instal PR + - name: Helm Install PR run: | helm upgrade --install --namespace $GITHUB_HEAD_REF bikesharing-$GITHUB_HEAD_REF samples/BikeSharingApp/Bikes/charts/bikes --set "image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes,image.tag=$GITHUB_SHA,imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }},ingress.hosts[0]=$GITHUB_HEAD_REF.s.${{ secrets.PARENT_SPACE }}.bikesharing.${{ secrets.HOST_SUFFIX }},ingress.annotations.\"kubernetes\\.io/ingress\\.class\"=traefik-azds" From a2abab9b6a668bb625ae6debbead3aba1679cea9 Mon Sep 17 00:00:00 2001 From: Nick Date: Wed, 2 Oct 2019 17:18:23 -0700 Subject: [PATCH 3/3] Change secret from PARENT_SPACE to MASTER_SPACE --- .github/workflows/bikes.yml | 4 ++-- .github/workflows/bikesharing.yml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml index 56c9c2a4e..4c58e17ef 100644 --- a/.github/workflows/bikes.yml +++ b/.github/workflows/bikes.yml @@ -34,7 +34,7 @@ jobs: 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.PARENT_SPACE }} + kubectl label namespace $GITHUB_HEAD_REF azds.io/parent-space=${{ secrets.MASTER_SPACE }} kubectl label namespace $GITHUB_HEAD_REF azds.io/space=true - uses: azure/k8s-actions/k8s-create-secret@master @@ -47,5 +47,5 @@ jobs: - name: Helm Install PR run: | - helm upgrade --install --namespace $GITHUB_HEAD_REF bikesharing-$GITHUB_HEAD_REF samples/BikeSharingApp/Bikes/charts/bikes --set "image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes,image.tag=$GITHUB_SHA,imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }},ingress.hosts[0]=$GITHUB_HEAD_REF.s.${{ secrets.PARENT_SPACE }}.bikesharing.${{ secrets.HOST_SUFFIX }},ingress.annotations.\"kubernetes\\.io/ingress\\.class\"=traefik-azds" + helm upgrade --install --namespace $GITHUB_HEAD_REF bikesharing-$GITHUB_HEAD_REF samples/BikeSharingApp/Bikes/charts/bikes --set "image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes,image.tag=$GITHUB_SHA,imagePullSecrets[0].name=${{ secrets.IMAGE_PULL_SECRET }},ingress.hosts[0]=$GITHUB_HEAD_REF.s.${{ secrets.MASTER_SPACE }}.bikesharing.${{ secrets.HOST_SUFFIX }},ingress.annotations.\"kubernetes\\.io/ingress\\.class\"=traefik-azds" diff --git a/.github/workflows/bikesharing.yml b/.github/workflows/bikesharing.yml index b94805a88..045f95802 100644 --- a/.github/workflows/bikesharing.yml +++ b/.github/workflows/bikesharing.yml @@ -54,4 +54,4 @@ jobs: cd samples/BikeSharingApp/charts helm init --client-only helm dependency update - helm upgrade --install --namespace ${{ secrets.PARENT_SPACE }} bikesharing . --set "bikes.image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes, bikesharingweb.image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikesharingweb, billing.image.repository=${{ secrets.CONTAINER_REGISTRY }}/billing, gateway.image.repository=${{ secrets.CONTAINER_REGISTRY }}/gateway, reservation.image.repository=${{ secrets.CONTAINER_REGISTRY }}/reservation, reservationengine.image.repository=${{ secrets.CONTAINER_REGISTRY }}/reservationengine, users.image.repository=${{ secrets.CONTAINER_REGISTRY }}/users, image.tag=$GITHUB_SHA" + helm upgrade --install --namespace ${{ secrets.MASTER_SPACE }} bikesharing . --set "bikes.image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikes, bikesharingweb.image.repository=${{ secrets.CONTAINER_REGISTRY }}/bikesharingweb, billing.image.repository=${{ secrets.CONTAINER_REGISTRY }}/billing, gateway.image.repository=${{ secrets.CONTAINER_REGISTRY }}/gateway, reservation.image.repository=${{ secrets.CONTAINER_REGISTRY }}/reservation, reservationengine.image.repository=${{ secrets.CONTAINER_REGISTRY }}/reservationengine, users.image.repository=${{ secrets.CONTAINER_REGISTRY }}/users, image.tag=$GITHUB_SHA"