pipeline fastapi CORS added #26
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{# name: Deploy Apache Superset | ||
on: | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Debug Environment Variables | ||
run: | | ||
echo "GCP_PROJECT_ID=$GCP_PROJECT_ID" | ||
echo "GCP_WORKLOAD_IDENTITY_POOL=$GCP_WORKLOAD_IDENTITY_POOL" | ||
echo "GCP_SERVICE_ACCOUNT_EMAIL=$GCP_SERVICE_ACCOUNT_EMAIL" | ||
- name: Authenticate to Google Cloud | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
project_id: $GCP_PROJECT_ID | ||
workload_identity_provider: $GCP_WORKLOAD_IDENTITY_POOL | ||
service_account: $GCP_SERVICE_ACCOUNT_EMAIL | ||
- name: Verify Google Cloud Authentication | ||
run: | | ||
gcloud auth list | ||
- name: Create Google Compute Engine instance | ||
run: | | ||
gcloud compute instances create superset-instance \ | ||
--project=$GCP_PROJECT_ID \ | ||
--zone=us-central1-a \ | ||
--machine-type=e2-medium \ | ||
--boot-disk-size=20GB \ | ||
--image-family=ubuntu-2204-lts \ | ||
--image-project=ubuntu-os-cloud \ | ||
--tags=http-server,https-server | ||
sleep 30 # Wait for instance to start | ||
- name: Install Docker and Docker Compose on the VM | ||
run: | | ||
gcloud compute ssh superset-instance --zone=us-central1-a --command=" | ||
sudo apt update && | ||
sudo apt install apt-transport-https ca-certificates curl software-properties-common -y && | ||
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - && | ||
sudo add-apt-repository 'deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable' && | ||
sudo apt update && | ||
sudo apt install docker-ce docker-ce-cli containerd.io -y && | ||
sudo curl -L 'https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)' -o /usr/local/bin/docker-compose && | ||
sudo chmod +x /usr/local/bin/docker-compose && | ||
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose | ||
" | ||
- name: Clone Superset repository and start Docker Compose | ||
run: | | ||
gcloud compute ssh superset-instance --zone=us-central1-a --command=" | ||
git clone https://github.com/apache/superset.git && | ||
cd superset/contrib/docker && | ||
echo \"SUPERSET_SECRET_KEY=${{ secrets.SUPERSET_SECRET_KEY }}\" > .env && | ||
echo \"SQLALCHEMY_DATABASE_URI=${{ secrets.SQLALCHEMY_DATABASE_URI }}\" >> .env && | ||
echo \"REDIS_URL=${{ secrets.REDIS_URL }}\" >> .env && | ||
echo \"PYTHONPATH=/app/pythonpath\" >> .env && | ||
echo \"SUPERSET_LOAD_EXAMPLES=yes\" >> .env && | ||
echo \"SUPERSET_PORT=8088\" >> .env && | ||
sudo docker-compose --env-file .env -f docker-compose-non-dev.yml up -d | ||
" | ||
- name: Wait for containers to be up | ||
run: | | ||
gcloud compute ssh superset-instance --zone=us-central1-a --command=" | ||
while ! sudo docker-compose -f superset/contrib/docker/docker-compose-non-dev.yml ps -q | xargs sudo docker inspect -f '{{ .State.Health.Status }}' | grep -v healthy; do | ||
sleep 5 | ||
done | ||
" | ||
- name: Create Superset admin user and initialize database | ||
run: | | ||
gcloud compute ssh superset-instance --zone=us-central1-a --command=" | ||
sudo docker exec superset_app superset fab create-admin \ | ||
--username admin --firstname Admin --lastname User --email [email protected] --password admin && | ||
sudo docker exec superset_app superset db upgrade && | ||
sudo docker exec superset_app superset init | ||
" | ||
- name: Output Superset public IP address | ||
run: | | ||
gcloud compute instances describe superset-instance \ | ||
--zone=us-central1-a \ | ||
--format='get(networkInterfaces[0].accessConfigs[0].natIP)' #} |