DESTROY Terraform on INFRA TEST #5
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
# in case the infra-test pipeline is being weird, run this manually to tear it down and then rebuil with another gh action | |
name: DESTROY Terraform on INFRA TEST | |
on: | |
workflow_dispatch: | |
jobs: | |
build-ingestion: | |
if: github.repository == 'SatcherInstitute/health-equity-tracker' | |
name: Build and Push Data Ingestion Image | |
runs-on: ubuntu-latest | |
outputs: | |
image-digest: ${{ steps.ingestion.outputs.image-digest }} | |
steps: | |
- name: Check Out Code | |
uses: actions/checkout@v4 | |
- id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.TEST_DEPLOYER_SA_KEY }} | |
- name: Set Up gcloud | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ secrets.TEST_PROJECT_ID }} | |
- id: ingestion | |
uses: ./.github/actions/buildAndPush | |
with: | |
dockerfile: 'run_ingestion/Dockerfile' | |
image-path: 'gcr.io/${{ secrets.TEST_PROJECT_ID }}/data-ingestion' | |
build-gcs-to-bq: | |
if: github.repository == 'SatcherInstitute/health-equity-tracker' | |
name: Build and Push GCS-to-BQ Image | |
runs-on: ubuntu-latest | |
outputs: | |
image-digest: ${{ steps.gcstobq.outputs.image-digest }} | |
steps: | |
- name: Check Out Code | |
uses: actions/checkout@v4 | |
- id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.TEST_DEPLOYER_SA_KEY }} | |
- name: Set Up gcloud | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ secrets.TEST_PROJECT_ID }} | |
- id: gcstobq | |
uses: ./.github/actions/buildAndPush | |
with: | |
ahr-api-key: ${{ secrets.AHR_API_KEY }} | |
dockerfile: 'run_gcs_to_bq/Dockerfile' | |
image-path: 'gcr.io/${{ secrets.TEST_PROJECT_ID }}/gcs-to-bq' | |
build-exporter: | |
if: github.repository == 'SatcherInstitute/health-equity-tracker' | |
name: Build and Push Exporter Image | |
runs-on: ubuntu-latest | |
outputs: | |
image-digest: ${{ steps.exporter.outputs.image-digest }} | |
steps: | |
- name: Check Out Code | |
uses: actions/checkout@v4 | |
- id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.TEST_DEPLOYER_SA_KEY }} | |
- name: Set Up gcloud | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ secrets.TEST_PROJECT_ID }} | |
- id: exporter | |
uses: ./.github/actions/buildAndPush | |
with: | |
dockerfile: 'exporter/Dockerfile' | |
image-path: 'gcr.io/${{ secrets.TEST_PROJECT_ID }}/exporter' | |
build-data-server: | |
if: github.repository == 'SatcherInstitute/health-equity-tracker' | |
name: Build and Push Data Server Image | |
runs-on: ubuntu-latest | |
outputs: | |
image-digest: ${{ steps.serving.outputs.image-digest }} | |
steps: | |
- name: Check Out Code | |
uses: actions/checkout@v4 | |
- id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.TEST_DEPLOYER_SA_KEY }} | |
- name: Set Up gcloud | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ secrets.TEST_PROJECT_ID }} | |
- id: serving | |
uses: ./.github/actions/buildAndPush | |
with: | |
dockerfile: 'data_server/Dockerfile' | |
image-path: 'gcr.io/${{ secrets.TEST_PROJECT_ID }}/data-server' | |
build-frontend: | |
if: github.repository == 'SatcherInstitute/health-equity-tracker' | |
name: Build and Push Frontend Image | |
runs-on: ubuntu-latest | |
outputs: | |
image-digest: ${{ steps.frontend.outputs.image-digest }} | |
steps: | |
- name: Check Out Code | |
uses: actions/checkout@v4 | |
- id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.TEST_DEPLOYER_SA_KEY }} | |
- name: Set Up gcloud | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ secrets.TEST_PROJECT_ID }} | |
- id: frontend | |
uses: ./.github/actions/buildAndPush | |
with: | |
dockerfile: 'frontend_server/Dockerfile' | |
image-path: 'gcr.io/${{ secrets.TEST_PROJECT_ID }}/frontend' | |
deploy-context: 'staging' | |
basic-auth-username: ${{ secrets.BASIC_AUTH_USERNAME }} | |
basic-auth-password: ${{ secrets.BASIC_AUTH_PASSWORD }} | |
deploy: | |
if: github.repository == 'SatcherInstitute/health-equity-tracker' | |
name: Destroy on Test Environment | |
runs-on: ubuntu-latest | |
needs: [build-ingestion, build-gcs-to-bq, build-exporter, build-data-server, build-frontend] | |
steps: | |
- name: Check Out Code | |
uses: actions/checkout@v4 | |
- id: auth | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.TEST_DEPLOYER_SA_KEY }} | |
- name: Set Up gcloud | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: ${{ secrets.TEST_PROJECT_ID }} | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
# Disable wrapper to enable access to terraform output. | |
with: | |
terraform_wrapper: false | |
- name: Save credentials | |
working-directory: ./config | |
run: | | |
cat > creds.json << EOF | |
${{ secrets.TEST_DEPLOYER_SA_KEY }} | |
EOF | |
- name: Terraform Init | |
working-directory: ./config | |
run: | | |
terraform init -backend-config="bucket=${{ secrets.TEST_TF_STATE_BUCKET }}" \ | |
-backend-config="credentials=creds.json" | |
- name: Terraform Destroy | |
id: terraform | |
working-directory: ./config | |
run: | | |
terraform destroy -auto-approve -var-file=test/test.tfvars \ | |
-var-file=common.tfvars \ | |
-var 'gcp_credentials=${{ secrets.TEST_DEPLOYER_SA_KEY }}' \ | |
-var 'project_id=${{ secrets.TEST_PROJECT_ID }}' \ | |
-var 'ingestion_image_digest=${{ needs.build-ingestion.outputs.image-digest }}' \ | |
-var 'gcs_to_bq_image_digest=${{ needs.build-gcs-to-bq.outputs.image-digest }}' \ | |
-var 'data_server_image_digest=${{ needs.build-data-server.outputs.image-digest }}' \ | |
-var 'exporter_image_digest=${{ needs.build-exporter.outputs.image-digest }}' \ | |
-var 'frontend_image_digest=${{ needs.build-frontend.outputs.image-digest }}' | |
data_server_url=$(terraform output data_server_url) | |
echo "data_server_url=$data_server_url" >> $GITHUB_OUTPUT | |
ingestion_url=$(terraform output ingestion_url) | |
echo "ingestion_url=$ingestion_url" >> $GITHUB_OUTPUT | |
gcs_to_bq_url=$(terraform output gcs_to_bq_url) | |
echo "gcs_to_bq_url=$gcs_to_bq_url" >> $GITHUB_OUTPUT | |
exporter_url=$(terraform output exporter_url) | |
echo "exporter_url=$exporter_url" >> $GITHUB_OUTPUT | |
frontend_url=$(terraform output frontend_url) | |
echo "frontend_url=$frontend_url" >> $GITHUB_OUTPUT |