dynamic geos and ranks #129
This file contains hidden or 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: Tech Report API Pipeline | |
on: [push] | |
env: | |
PIPELINE_SA_KEY: ${{ secrets.GCP_SA_KEY }} | |
PIPELINE_GOOGLE_SERVICE_ACCOUNT_CLOUD_FUNCTIONS: ${{ secrets.GCP_SERVICE_ACCOUNT_CLOUD_FUNCTIONS }} | |
PIPELINE_GOOGLE_SERVICE_ACCOUNT_API_GATEWAY: ${{ secrets.GCP_SERVICE_ACCOUNT_API_GATEWAY }} | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- run: | | |
cd src | |
npm ci | |
npm run test | |
deploy_development: | |
if: github.ref == 'refs/heads/development' | |
runs-on: ubuntu-latest | |
needs: [test] | |
defaults: | |
run: | |
working-directory: ./terraform/dev | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Google Cloud Auth | |
uses: 'google-github-actions/auth@v2' | |
with: | |
project_id: 'httparchive' | |
credentials_json: ${{ env.PIPELINE_SA_KEY }} | |
- uses: hashicorp/setup-terraform@v3 | |
- name: Terraform fmt | |
id: fmt | |
run: terraform fmt -check | |
continue-on-error: true | |
- name: Terraform Init | |
id: init | |
run: terraform init | |
- name: Terraform Validate | |
id: validate | |
run: terraform validate -no-color | |
- name: Terraform Plan | |
id: plan | |
run: | | |
terraform plan -no-color -var="google_service_account_cloud_functions=${{ env.PIPELINE_GOOGLE_SERVICE_ACCOUNT_CLOUD_FUNCTIONS }}" \ | |
-var="google_service_account_api_gateway=${{ env.PIPELINE_GOOGLE_SERVICE_ACCOUNT_API_GATEWAY }}" | |
continue-on-error: true | |
- name: Terraform Plan status | |
if: steps.plan.outcome == 'failure' | |
run: exit 1 | |
- name: Terraform Apply | |
id: apply | |
run: | | |
terraform apply -var="google_service_account_cloud_functions=${{ env.PIPELINE_GOOGLE_SERVICE_ACCOUNT_CLOUD_FUNCTIONS }}" \ | |
-var="google_service_account_api_gateway=${{ env.PIPELINE_GOOGLE_SERVICE_ACCOUNT_API_GATEWAY }}" \ | |
-auto-approve | |
deploy_production: | |
if: github.ref == 'refs/heads/main' | |
runs-on: ubuntu-latest | |
needs: [test] | |
defaults: | |
run: | |
working-directory: ./terraform/prod | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Google Cloud Auth | |
uses: 'google-github-actions/auth@v2' | |
with: | |
project_id: 'httparchive' | |
credentials_json: ${{ env.PIPELINE_SA_KEY }} | |
- uses: hashicorp/setup-terraform@v3 | |
- name: Terraform fmt | |
id: fmt | |
run: terraform fmt -check | |
continue-on-error: true | |
- name: Terraform Init | |
id: init | |
run: terraform init | |
- name: Terraform Validate | |
id: validate | |
run: terraform validate -no-color | |
- name: Terraform Plan | |
id: plan | |
run: | | |
terraform plan -no-color -var="google_service_account_cloud_functions=${{ env.PIPELINE_GOOGLE_SERVICE_ACCOUNT_CLOUD_FUNCTIONS }}" \ | |
-var="google_service_account_api_gateway=${{ env.PIPELINE_GOOGLE_SERVICE_ACCOUNT_API_GATEWAY }}" | |
continue-on-error: true | |
- name: Terraform Plan status | |
if: steps.plan.outcome == 'failure' | |
run: exit 1 | |
- name: Terraform Apply | |
id: apply | |
run: | | |
terraform apply -var="google_service_account_cloud_functions=${{ env.PIPELINE_GOOGLE_SERVICE_ACCOUNT_CLOUD_FUNCTIONS }}" \ | |
-var="google_service_account_api_gateway=${{ env.PIPELINE_GOOGLE_SERVICE_ACCOUNT_API_GATEWAY }}" \ | |
-auto-approve | |