forked from DapperCollectives/CAST
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c586ba7
commit b4102b5
Showing
2 changed files
with
193 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
name: "Deploy to Production Cloud Run" | ||
|
||
on: | ||
push: | ||
branches: | ||
- prod-gcp | ||
- jp-testing | ||
|
||
env: | ||
|
||
# DB VARS | ||
db_username: ${{ secrets.DB_USERNAME }} | ||
db_password: ${{ secrets.DB_PASSWORD }} | ||
db_hostname: ${{ secrets.DB_HOSTNAME }} | ||
db_port: ${{ secrets.DB_PORT }} | ||
db_name: ${{ secrets.DB_NAME }} | ||
backend_api: ${{ secrets.BACKEND_API }} | ||
tx_options: ${{ secrets.TX_OPTIONS }} | ||
hotjar_site_id: ${{ secrets.HOTJAR_STAGE_ID }} | ||
sentry_url: ${{ secrets.SENTRY_STAGE_URL }} | ||
|
||
# GCP VARS | ||
BACKEND_DOCKER_IMAGE_URL: ${{ vars.BACKEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} | ||
FRONTEND_DOCKER_IMAGE_URL: ${{ vars.FRONTNED_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} | ||
GAR_LOCATION: ${{ vars.GCP_GAR_LOCATION }} | ||
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} | ||
SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }} | ||
WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Google auth | ||
id: auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
token_format: 'access_token' | ||
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ env.SERVICE_ACCOUNT }} | ||
|
||
- name: Set up Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v1 | ||
with: | ||
project_id: ${{ env.PROJECT_ID }} | ||
|
||
- name: Build CAST Backend | ||
run: |- | ||
gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev | ||
docker build -t ${{ env.BACKEND_DOCKER_IMAGE_URL }} --file backend/Dockerfile ./backend | ||
docker push ${{ env.BACKEND_DOCKER_IMAGE_URL }} | ||
- name: Build CAST Frontend | ||
env: | ||
BACKEND: ${{ env.backend_api }} | ||
run: | | ||
gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev | ||
cd frontend && sed -i -e 's/REPLACE_HOTJAR_SITE_ID/${{ env.hotjar_site_id }}/g' Dockerfile.stage && sed -i -e 's|REPLACE_SENTRY_URL|${{ env.sentry_url }}|g' Dockerfile.stage && docker build -f Dockerfile.stage . -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} | ||
deploy-production-backend: | ||
needs: [build] | ||
environment: production | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Google auth | ||
id: auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
token_format: 'access_token' | ||
workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }} | ||
|
||
- name: Deploy Backend to Cloud Run | ||
uses: google-github-actions/deploy-cloudrun@v1 | ||
with: | ||
service: ${{ vars.BACKEND_GCP_SERVICE }} | ||
image: ${{ env.BACKEND_DOCKER_IMAGE_URL }} | ||
|
||
- name: Deploy Frontend to Cloud Run | ||
uses: google-github-actions/deploy-cloudrun@v1 | ||
with: | ||
service: ${{ vars.FRONTEND_GCP_SERVICE }} | ||
image: ${{ env.FRONTEND_DOCKER_IMAGE_URL }} | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: "Deploy to Staging Cloud Run" | ||
|
||
on: | ||
push: | ||
branches: | ||
- staging | ||
- jp/staging-cloud-run-prep | ||
|
||
env: | ||
|
||
# DB VARS | ||
db_username: ${{ secrets.DB_USERNAME }} | ||
db_password: ${{ secrets.DB_PASSWORD }} | ||
db_hostname: ${{ secrets.DB_HOSTNAME }} | ||
db_port: ${{ secrets.DB_PORT }} | ||
db_name: ${{ secrets.DB_NAME }} | ||
backend_api: ${{ secrets.BACKEND_API }} | ||
tx_options: ${{ secrets.TX_OPTIONS }} | ||
hotjar_site_id: ${{ secrets.HOTJAR_STAGE_ID }} | ||
sentry_url: ${{ secrets.SENTRY_STAGE_URL }} | ||
|
||
# GCP VARS | ||
BACKEND_DOCKER_IMAGE_URL: ${{ vars.BACKEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} | ||
FRONTEND_DOCKER_IMAGE_URL: ${{ vars.FRONTEND_GCP_DOCKER_IMAGE_URL }}:${{ github.sha }} | ||
GAR_LOCATION: ${{ vars.GCP_GAR_LOCATION }} | ||
PROJECT_ID: ${{ vars.GCP_PROJECT_ID }} | ||
SERVICE_ACCOUNT: ${{ vars.GCP_SERVICE_ACCOUNT }} | ||
WORKLOAD_IDENTITY_PROVIDER: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Google auth | ||
id: auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
token_format: 'access_token' | ||
workload_identity_provider: ${{ env.WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ env.SERVICE_ACCOUNT }} | ||
|
||
- name: Set up Cloud SDK | ||
uses: google-github-actions/setup-gcloud@v1 | ||
with: | ||
project_id: ${{ env.PROJECT_ID }} | ||
|
||
- name: Build & Push Backend | ||
run: |- | ||
gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev | ||
docker build -t ${{ env.BACKEND_DOCKER_IMAGE_URL }} --file backend/Dockerfile ./backend | ||
docker push ${{ env.BACKEND_DOCKER_IMAGE_URL }} | ||
- name: Build & Push Frontend | ||
env: | ||
BACKEND: ${{ env.backend_api }} | ||
run: | | ||
gcloud auth configure-docker ${{ env.GAR_LOCATION }}-docker.pkg.dev | ||
cd frontend && docker build -f Dockerfile.stage . -t ${{ env.FRONTEND_DOCKER_IMAGE_URL }} | ||
docker push ${{ env.FRONTEND_DOCKER_IMAGE_URL }} | ||
deploy-staging-backend: | ||
needs: [build] | ||
environment: staging | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
id-token: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- name: Google auth | ||
id: auth | ||
uses: google-github-actions/auth@v2 | ||
with: | ||
token_format: 'access_token' | ||
workload_identity_provider: ${{ vars.GCP_WORKLOAD_IDENTITY_PROVIDER }} | ||
service_account: ${{ vars.GCP_SERVICE_ACCOUNT }} | ||
|
||
- name: Deploy Backend to Cloud Run | ||
uses: google-github-actions/deploy-cloudrun@v1 | ||
with: | ||
service: ${{ vars.BACKEND_GCP_SERVICE }} | ||
image: ${{ env.BACKEND_DOCKER_IMAGE_URL }} | ||
|
||
- name: Deploy Frontend to Cloud Run | ||
uses: google-github-actions/deploy-cloudrun@v1 | ||
with: | ||
service: ${{ vars.FRONTEND_GCP_SERVICE }} | ||
image: ${{ env.FRONTEND_DOCKER_IMAGE_URL }} | ||
|