From 2a1a80056cab7810f45999222e80a267de530560 Mon Sep 17 00:00:00 2001 From: Thomas Meckel Date: Thu, 4 Jul 2024 17:03:06 +0000 Subject: [PATCH] cicd: replaced composite action with it's steps for deploy-test job --- .github/workflows/test_and_deploy.yml | 99 +++++++++++++++++++++++++-- 1 file changed, 93 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test_and_deploy.yml b/.github/workflows/test_and_deploy.yml index cc7fcf00..ca21bb4b 100644 --- a/.github/workflows/test_and_deploy.yml +++ b/.github/workflows/test_and_deploy.yml @@ -117,13 +117,100 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 - - id: deploy-infrastructure-test - name: Deploy Infrastructure - uses: ./.github/actions/deploy_infrastructure + - name: Install Python + uses: actions/setup-python@v5 + with: + python-version: ${{ inputs.python-version }} + + - name: Get pip cache dir + id: pip-cache + shell: bash + run: | + python -m pip install pip --upgrade + echo "PIP_CACHE_DIR=$(python -m pip cache dir)" >> $GITHUB_ENV + + - name: Cache pip + uses: actions/cache@v4 + with: + path: ${{ env.PIP_CACHE_DIR }} + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements*.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Configure GCP Credentials + uses: google-github-actions/auth@v2 + with: + workload_identity_provider: "projects/734798842681/locations/global/workloadIdentityPools/my-pool/providers/gh-provider" + service_account: "git-cerulean-cloud@cerulean-338116.iam.gserviceaccount.com" + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v4 with: - environment: test - pulumi-version: 3.121.0 - pulumi-stack-passphrase: test + role-to-assume: arn:aws:iam::162277344632:role/CeruleanCloudDeploy + aws-region: eu-central-1 + + - name: Configure docker + shell: bash + run: | + gcloud auth configure-docker -q + + - name: Install Pulumi requirements + shell: bash + run: | + pip install -r requirements-pulumi.txt + + - name: Build Container Images + uses: pulumi/actions@v5 + id: pulumi-images + env: + PULUMI_CONFIG_PASSPHRASE: "test" + with: + pulumi-version: "3.121.0" + work-dir: images/ + command: up + stack-name: "test" + + - name: Prune Docker environment + shell: bash + run: | + docker container prune -f + docker buildx prune -f + docker images + + # Copy shared database_client.py files + - name: Copy Shared File + shell: bash + run: | + mkdir -p cerulean_cloud/cloud_function_ais_analysis/cerulean_cloud/ + cp cerulean_cloud/database_client.py cerulean_cloud/cloud_function_ais_analysis/cerulean_cloud/database_client.py + cp cerulean_cloud/database_schema.py cerulean_cloud/cloud_function_ais_analysis/cerulean_cloud/database_schema.py + cp cerulean_cloud/__init__.py cerulean_cloud/cloud_function_ais_analysis/cerulean_cloud/__init__.py + + - name: Deploy Infrastructure + uses: pulumi/actions@v5 + id: pulumi + env: + PULUMI_CONFIG_PASSPHRASE: "test" + MODEL: ${{ steps.pulumi-images.outputs.model }} + with: + pulumi-version: "3.121.0" + command: up + stack-name: "test" + refresh: true + diff: true + comment-on-summary: true + + - name: Start Google Cloud SQL Proxy + uses: wagnerpereira/gce-cloudsql-proxy-action@v2 + with: + instance: ${{ steps.pulumi.outputs.database_instance_name }} + + - name: Run database migrations + shell: bash + env: + DB_URL: ${{ steps.pulumi.outputs.database_url_alembic }} + run: | + pip install -r requirements.txt && alembic upgrade head deploy-staging: name: Deploy [STAGING]