[Documentation] Add warning message #15
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 query API and documentation' | |
on: | |
push: | |
pull_request: | |
jobs: | |
run_tests: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./query_api | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Run tests in Docker container | |
run: | | |
docker build -t query-api . | |
docker run --rm query-api:latest pytest tests/integration.py | |
deploy_query_api: | |
needs: run_tests | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./query_api | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Configure Docker | |
if: github.ref == 'refs/heads/main' # Only run on main branch | |
run: echo $GOOGLE_CREDENTIALS | gcloud auth activate-service-account --key-file=- && gcloud auth configure-docker | |
env: | |
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
if: github.ref == 'refs/heads/main' # Only run on main branch | |
with: | |
context: ./query_api | |
file: ./query_api/Dockerfile | |
push: true | |
tags: gcr.io/${{ secrets.GCP_PROJECT_ID }}/query-api:latest | |
env: | |
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v1 | |
with: | |
terraform_version: 1.5.4 | |
- name: Setup Google Credentials | |
run: echo '${{ secrets.GOOGLE_CREDENTIALS }}' > ./google_credentials.json | |
env: | |
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} | |
- name: Terraform Init | |
run: terraform init -lock=false | |
env: | |
TF_VAR_gcp_project_id: ${{ secrets.GCP_PROJECT_ID }} | |
TF_VAR_gcp_region: ${{ secrets.GCP_REGION }} | |
TF_VAR_credentials_path: ./google_credentials.json | |
- name: Terraform Validate | |
run: terraform validate | |
- name: Terraform Plan | |
run: terraform plan -lock=false | |
if: github.ref == 'refs/heads/main' # Only run on main branch | |
env: | |
TF_VAR_gcp_project_id: ${{ secrets.GCP_PROJECT_ID }} | |
TF_VAR_gcp_region: ${{ secrets.GCP_REGION }} | |
TF_VAR_mongo_connection_string: ${{ secrets.MONGO_CONNECTION_STRING }} | |
TF_VAR_credentials_path: ./google_credentials.json | |
TF_VAR_logging_bucket_name: ${{ secrets.QUERY_API_LOGGING_BUCKET_NAME }} | |
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} | |
- name: Terraform Apply | |
run: terraform apply -auto-approve -lock=false | |
if: github.ref == 'refs/heads/main' # Only run on main branch | |
env: | |
TF_VAR_gcp_project_id: ${{ secrets.GCP_PROJECT_ID }} | |
TF_VAR_gcp_region: ${{ secrets.GCP_REGION }} | |
TF_VAR_mongo_connection_string: ${{ secrets.MONGO_CONNECTION_STRING }} | |
TF_VAR_credentials_path: ./google_credentials.json | |
TF_VAR_logging_bucket_name: ${{ secrets.QUERY_API_LOGGING_BUCKET_NAME }} | |
GOOGLE_CREDENTIALS: ${{ secrets.GOOGLE_CREDENTIALS }} | |
update_documentation: | |
needs: run_tests | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
working-directory: ./documentation | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v2 | |
- name: Build Slate documentation | |
run: | | |
(pip install -r ../query_api/requirements.txt && python generate.py) | |
docker run --rm --name slate -v $(pwd)/build:/srv/slate/build -v $(pwd)/source:/srv/slate/source slatedocs/slate build | |
- name: Deploy documentation to Github Pages | |
uses: JamesIves/github-pages-deploy-action@v4 | |
if: github.ref == 'refs/heads/main' | |
with: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BRANCH: gh-pages | |
FOLDER: $(pwd)/../documentation/build | |
CLEAN: true |