Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #165 from Azure/add_github_actions
Browse files Browse the repository at this point in the history
Add bikes pr workflow and bikesharing workflow for GitHub Actions
  • Loading branch information
philon-msft authored Oct 3, 2019
2 parents 4a01fc9 + a2abab9 commit 5ce9013
Show file tree
Hide file tree
Showing 2 changed files with 108 additions and 0 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/bikes.yml
Original file line number Diff line number Diff line change
@@ -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"
57 changes: 57 additions & 0 deletions .github/workflows/bikesharing.yml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 5ce9013

Please sign in to comment.