|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one or more |
| 2 | +# contributor license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright ownership. |
| 4 | +# The ASF licenses this file to You under the Apache License, Version 2.0 |
| 5 | +# (the "License"); you may not use this file except in compliance with |
| 6 | +# the License. You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | + |
| 16 | +name: Collect And Deploy Playground Examples |
| 17 | + |
| 18 | +on: |
| 19 | + push: |
| 20 | + tags: 'v*' |
| 21 | + workflow_dispatch: |
| 22 | + |
| 23 | +jobs: |
| 24 | + deploy_examples: |
| 25 | + name: Deploy examples |
| 26 | + runs-on: ubuntu-latest |
| 27 | + env: |
| 28 | + BEAM_ROOT_DIR: ../../ |
| 29 | + BEAM_EXAMPLE_CATEGORIES: ../categories.yaml |
| 30 | + BEAM_VERSION: 2.33.0 |
| 31 | + SERVER_ADDRESS: backend-python-dot-datatokenization.uc.r.appspot.com |
| 32 | + K8S_NAMESPACE: playground-backend |
| 33 | + HELM_APP_NAME: playground-backend |
| 34 | + steps: |
| 35 | + - name: Check out the repo |
| 36 | + uses: actions/checkout@v2 |
| 37 | + - uses: actions/setup-python@v2 |
| 38 | + with: |
| 39 | + python-version: '3.8' |
| 40 | + - uses: actions/setup-java@v2 |
| 41 | + with: |
| 42 | + distribution: 'zulu' |
| 43 | + java-version: '8' |
| 44 | + - name: Install kubectl |
| 45 | + run: | |
| 46 | + curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" &&\ |
| 47 | + chmod +x kubectl &&\ |
| 48 | + mv kubectl /usr/local/bin/ |
| 49 | + - name: Install helm |
| 50 | + run: | |
| 51 | + curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 &&\ |
| 52 | + chmod 700 get_helm.sh &&\ |
| 53 | + ./get_helm.sh |
| 54 | + - name: Set up Cloud SDK |
| 55 | + uses: google-github-actions/setup-gcloud@v0.3.0 |
| 56 | + - name: install deps |
| 57 | + run: pip install -r requirements.txt |
| 58 | + working-directory: playground/infrastructure |
| 59 | + - name: Setup GCP account |
| 60 | + run: | |
| 61 | + echo "${{ secrets.GCP_ACCESS_KEY }}" | base64 -d > /tmp/gcp_access.json |
| 62 | + gcloud auth activate-service-account --project=datatokenization --key-file=/tmp/gcp_access.json |
| 63 | + - name: Get K8s Config |
| 64 | + run: gcloud container clusters get-credentials --region us-central1-a playground-examples |
| 65 | + - name: Login to Docker Registry |
| 66 | + run: cat /tmp/gcp_access.json | docker login -u _json_key --password-stdin https://${{ secrets.REGISTRY_NAME }} |
| 67 | + - name: Build And Push Java Backend |
| 68 | + run: ./gradlew playground:backend:containers:java:dockerTagPush -Pdocker-repository-root='${{ secrets.REGISTRY_NAME}}/${{ secrets.PROJECT_ID }}/playground-repository' -Pbase-image='apache/beam_java8_sdk:${{ env.BEAM_VERSION }}' -Pdocker-tag="$GITHUB_SHA" |
| 69 | + - name: Build And Push Go Backend |
| 70 | + run: ./gradlew playground:backend:containers:go:dockerTagPush -Pdocker-repository-root='${{ secrets.REGISTRY_NAME}}/${{ secrets.PROJECT_ID }}/playground-repository' -Pdocker-tag="$GITHUB_SHA" |
| 71 | + - name: Build And Push Python Backend |
| 72 | + run: ./gradlew playground:backend:containers:python:dockerTagPush -Pdocker-repository-root='${{ secrets.REGISTRY_NAME}}/${{ secrets.PROJECT_ID }}/playground-repository' -Pdocker-tag="$GITHUB_SHA" |
| 73 | + - name: Install helm chart |
| 74 | + run: | |
| 75 | + kubectl create namespace $K8S_NAMESPACE --dry-run=client -o yaml | kubectl apply -f - &&\ |
| 76 | + helm install --namespace $K8S_NAMESPACE $HELM_APP_NAME . --set global.registry="${{ secrets.REGISTRY_NAME }}/${{ secrets.PROJECT_ID }}/playground-repository" --set global.tag="$GITHUB_SHA" &&\ |
| 77 | + sleep 120 |
| 78 | + working-directory: playground/infrastructure/helm |
| 79 | + - name: Run Python Examples CI |
| 80 | + run: | |
| 81 | + K8S_SERVER_ADDRESS=$(kubectl get svc -n $K8S_NAMESPACE -l "app=service-python" -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}') |
| 82 | + BEAM_ROOT_DIR="../../" |
| 83 | + BEAM_EXAMPLE_CATEGORIES="../../playground/categories.yaml" |
| 84 | + export SERVER_ADDRESS="$K8S_SERVER_ADDRESS:8081" && python3 ci_cd.py --step CI --sdk SDK_PYTHON |
| 85 | + working-directory: playground/infrastructure |
| 86 | + - name: Run Python Examples CD |
| 87 | + run: | |
| 88 | + K8S_SERVER_ADDRESS=$(kubectl get svc -n $K8S_NAMESPACE -l "app=service-python" -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}') |
| 89 | + BEAM_ROOT_DIR="../../" |
| 90 | + BEAM_EXAMPLE_CATEGORIES="../../playground/categories.yaml" |
| 91 | + export SERVER_ADDRESS="$K8S_SERVER_ADDRESS:8081" && python3 ci_cd.py --step CD --sdk SDK_PYTHON |
| 92 | + working-directory: playground/infrastructure |
| 93 | + env: |
| 94 | + GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp_access.json |
| 95 | + - name: Run Go Examples CI |
| 96 | + run: | |
| 97 | + K8S_SERVER_ADDRESS=$(kubectl get svc -n $K8S_NAMESPACE -l "app=service-go" -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}') |
| 98 | + BEAM_ROOT_DIR="../../" |
| 99 | + BEAM_EXAMPLE_CATEGORIES="../../playground/categories.yaml" |
| 100 | + export SERVER_ADDRESS="$K8S_SERVER_ADDRESS:8082" && python3 ci_cd.py --step CI --sdk SDK_GO |
| 101 | + working-directory: playground/infrastructure |
| 102 | + - name: Run Go Examples CD |
| 103 | + run: | |
| 104 | + K8S_SERVER_ADDRESS=$(kubectl get svc -n $K8S_NAMESPACE -l "app=service-go" -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}') |
| 105 | + BEAM_ROOT_DIR="../../" |
| 106 | + BEAM_EXAMPLE_CATEGORIES="../../playground/categories.yaml" |
| 107 | + export SERVER_ADDRESS="$K8S_SERVER_ADDRESS:8082" && python3 ci_cd.py --step CD --sdk SDK_GO |
| 108 | + working-directory: playground/infrastructure |
| 109 | + env: |
| 110 | + GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp_access.json |
| 111 | + - name: Run Java Examples CI |
| 112 | + run: | |
| 113 | + K8S_SERVER_ADDRESS=$(kubectl get svc -n $K8S_NAMESPACE -l "app=service-java" -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}') |
| 114 | + BEAM_ROOT_DIR="../../" |
| 115 | + BEAM_EXAMPLE_CATEGORIES="../../playground/categories.yaml" |
| 116 | + export SERVER_ADDRESS="$K8S_SERVER_ADDRESS:8080" && python3 ci_cd.py --step CI --sdk SDK_JAVA |
| 117 | + working-directory: playground/infrastructure |
| 118 | + - name: Run Java Examples CD |
| 119 | + run: | |
| 120 | + K8S_SERVER_ADDRESS=$(kubectl get svc -n $K8S_NAMESPACE -l "app=service-java" -o jsonpath='{.items[0].status.loadBalancer.ingress[0].ip}') |
| 121 | + BEAM_ROOT_DIR="../../" |
| 122 | + BEAM_EXAMPLE_CATEGORIES="../../playground/categories.yaml" |
| 123 | + export SERVER_ADDRESS="$K8S_SERVER_ADDRESS:8080" && python3 ci_cd.py --step CD --sdk SDK_JAVA |
| 124 | + working-directory: playground/infrastructure |
| 125 | + env: |
| 126 | + GOOGLE_APPLICATION_CREDENTIALS: /tmp/gcp_access.json |
| 127 | + - name: Delete Helm Chart |
| 128 | + run: | |
| 129 | + helm del --namespace $K8S_NAMESPACE $HELM_APP_NAME |
0 commit comments