Skip to content

Commit

Permalink
chore: add production release GitHub action (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidgamez authored Feb 28, 2024
1 parent 1e33589 commit 2c9d680
Show file tree
Hide file tree
Showing 18 changed files with 227 additions and 101 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/api-deployer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,12 @@ jobs:

- name: Authenticate to Google Cloud
id: gcloud_auth
uses: google-github-actions/auth@v1
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_MOBILITY_FEEDS_SA_KEY }}

- name: GCloud Setup
uses: google-github-actions/setup-gcloud@v1
uses: google-github-actions/setup-gcloud@v2

- name: Set Variables
run: |
Expand Down Expand Up @@ -130,6 +130,7 @@ jobs:
with:
name: terraform-artifact-plan.txt
path: infra/artifact-registry/terraform-plan.txt
overwrite: true

docker-build-publish:
# Add docker healthy test
Expand All @@ -152,7 +153,7 @@ jobs:

- name: Authenticate to Google Cloud
id: gcloud_auth
uses: google-github-actions/auth@v1
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_MOBILITY_FEEDS_SA_KEY }}

Expand Down Expand Up @@ -253,12 +254,12 @@ jobs:
- name: Authenticate to Google Cloud
id: gcloud_auth
uses: google-github-actions/auth@v1
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_MOBILITY_FEEDS_SA_KEY }}

- name: GCloud Setup
uses: google-github-actions/setup-gcloud@v1
uses: google-github-actions/setup-gcloud@v2

- name: Set Variables
run: |
Expand Down Expand Up @@ -313,3 +314,4 @@ jobs:
with:
name: terraform-plan.txt
path: infra/terraform-plan.txt
overwrite: true
11 changes: 1 addition & 10 deletions .github/workflows/api-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
name: Deploy Feeds API - PROD
on:
workflow_dispatch: # Supports manual deployment
release:
workflow_call:

jobs:
api-build-deployment:
Expand All @@ -21,12 +21,3 @@ jobs:
GCP_MOBILITY_FEEDS_SA_KEY: ${{ secrets.PROD_GCP_MOBILITY_FEEDS_SA_KEY }}
OAUTH2_CLIENT_ID: ${{ secrets.PROD_MOBILITY_FEEDS_OAUTH2_CLIENT_ID}}
OAUTH2_CLIENT_SECRET: ${{ secrets.PROD_MOBILITY_FEEDS_OAUTH2_CLIENT_SECRET}}

integration-tests:
uses: ./.github/workflows/integration-tests.yml
needs:
- api-build-deployment
with:
API_URL: 'https://api.mobilitydatabase.org'
secrets:
REFRESH_TOKEN: ${{ secrets.PROD_API_TEST_REFRESH_TOKEN }}
8 changes: 7 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
branches: [ main ]
paths-ignore:
- '**.md'
- "web-app/**"
- "functions/**"
- ".github/workflows/web-*.yml"
workflow_call:

env:
Expand Down Expand Up @@ -102,15 +105,18 @@ jobs:
with:
name: coverage_report
path: scripts/coverage_reports/
overwrite: true

- name: Upload DB models
uses: actions/upload-artifact@v4
with:
name: database_gen
path: api/src/database_gen/
overwrite: true

- name: API generated code
uses: actions/upload-artifact@v4
with:
name: feeds_gen
path: api/src/feeds_gen/
path: api/src/feeds_gen/
overwrite: true
2 changes: 1 addition & 1 deletion .github/workflows/datasets-batch-deployer-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy Historical Batch Processing - PROD

on:
workflow_dispatch: # Supports manual deployment
release:
workflow_call:

jobs:
deploy:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/datasets-batch-deployer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,16 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Authenticate to Google Cloud
id: gcloud_auth
uses: google-github-actions/auth@v1
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_MOBILITY_FEEDS_SA_KEY }}

- name: Google Cloud Setup
uses: google-github-actions/setup-gcloud@v1
uses: google-github-actions/setup-gcloud@v2

- name: Set Variables
run: |
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/db-deployer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ jobs:
db_instance_host: ${{ steps.get_outputs.outputs.db_instance_host }}
steps:
- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Authenticate to Google Cloud
id: gcloud_auth
uses: google-github-actions/auth@v1
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_MOBILITY_FEEDS_SA_KEY }}

- name: Google Cloud Setup
uses: google-github-actions/setup-gcloud@v1
uses: google-github-actions/setup-gcloud@v2

- name: Set Variables
run: |
Expand Down Expand Up @@ -154,12 +154,12 @@ jobs:
DB_INSTANCE_HOST: ${{ needs.terraform.outputs.db_instance_host }}
steps:
- name: Authenticate to Google Cloud DEV
uses: google-github-actions/auth@v1
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.DEV_GCP_MOBILITY_FEEDS_SA_KEY }}

- name: Google Cloud Setup DEV
uses: google-github-actions/setup-gcloud@v1
uses: google-github-actions/setup-gcloud@v2

- name: Create or Update Secret in DEV
run: |
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/db-prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
name: Deploy DB - PROD
on:
workflow_dispatch: # Supports manual deployment
workflow_call:

jobs:
deploy:
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/db-update-prod.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
# Update the Mobility Database Schema
name: Database Update - PROD
on:
release: # Update on merge on master if the changelog file has been updated
paths:
- "liquibase/changelog.xml"
workflow_dispatch:
workflow_call:
repository_dispatch: # Update on mobility-database-catalog repo dispatch
types: [ catalog-sources-updated ]
jobs:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/db-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ jobs:
run: scripts/populate-db.sh ${{ steps.getpath.outputs.PATH }} > populate.log

- name: Upload log file for verification
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: populate.log
path: populate.log
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
run: ./scripts/extract-hash-and-version.sh

- name: Set up Python 3.10
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'

Expand All @@ -49,7 +49,7 @@ jobs:
REFRESH_TOKEN: ${{ secrets.REFRESH_TOKEN }}

- name: Upload Test Logs
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: integration-tests-results
path: |
Expand Down
37 changes: 37 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Deploys all the resources to production environment
name: Production Release
on:
release:

jobs:
bd-deployment:
name: Database Deployment
uses: ./.github/workflows/db-prod.yml
secrets: inherit
bd-update:
name: Database Update
needs: bd-deployment
uses: ./.github/workflows/db-update-prod.yml
secrets: inherit
bash-deployment:
name: Bash Processes Deployment
needs: bd-update
uses: ./.github/workflows/datasets-batch-deployer-prod.yml
secrets: inherit
api-deployment:
name: API Deployment
needs: bash-deployment
uses: ./.github/workflows/api-prod.yml
secrets: inherit
integration-tests:
uses: ./.github/workflows/integration-tests.yml
needs: api-deployment
with:
API_URL: "https://api.mobilitydatabase.org"
secrets:
REFRESH_TOKEN: ${{ secrets.PROD_API_TEST_REFRESH_TOKEN }}
web-deployment:
name: Web Deployment
needs: bash-deployment
uses: ./.github/workflows/web-prod.yml
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/schedule-load-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: "3.x"

Expand Down Expand Up @@ -52,7 +52,7 @@ jobs:
-u ${LOCUST_USERS} -r ${LOCUST_RATE} --headless -t ${LOCUST_DURATION} --only-summary --csv locust_results
- name: Upload load test results as artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: load_test_results
path: locust_results_*
Loading

0 comments on commit 2c9d680

Please sign in to comment.