diff --git a/.github/workflows/bikes.yml b/.github/workflows/bikes.yml new file mode 100644 index 000000000..4c58e17ef --- /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.MASTER_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 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.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 new file mode 100644 index 000000000..045f95802 --- /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.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"