Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
JuribaDev committed Sep 1, 2024
1 parent 73ccc4c commit 41223e8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
40 changes: 23 additions & 17 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:

env:
LOCATION: me-central1
CLIENT_ENV_PATH: apps/client/src/environments/environment.prod.ts


steps:
Expand All @@ -35,17 +36,6 @@ jobs:
run: |
gcloud auth configure-docker ${{env.LOCATION}}-docker.pkg.dev
- name: Build and push Docker image for client
run: |
docker build \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg GITHUB_SHA=${{ github.sha }} \
--build-arg GITHUB_REF_NAME=${{ github.ref_name }} \
-f apps/client/Dockerfile \
-t ${{env.LOCATION}}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.REPO_NAME }}/client:${{ github.sha }}-${{ github.ref_name }} \
.
docker push ${{env.LOCATION}}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.REPO_NAME }}/client:${{ github.sha }}-${{ github.ref_name }}
- name: Build and push Docker image for server
run: |
Expand All @@ -58,7 +48,6 @@ jobs:
.
docker push ${{env.LOCATION}}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.REPO_NAME }}/server:${{ github.sha }}-${{ github.ref_name }}
- name: Deploy Server to Cloud Run
id: deploy-server
uses: google-github-actions/deploy-cloudrun@v2
Expand All @@ -78,27 +67,44 @@ jobs:
--min-instances 1
--concurrency 80
--allow-unauthenticated
--ingress=all
--ingress=internal
timeout: 600s

- name: Set the api url in the client
run: |
# Set correct permissions for environment.prod variables
sudo chmod 777 ${{env.CLIENT_ENV_PATH}}
# Update Kubernetes manifests with secrets and environment variables
sed -i "s|API_URL_PLACEHOLDER|${{ steps.deploy-server.outputs.url }}|g" ${{env.CLIENT_ENV_PATH}}
- name: Build and push Docker image for client
run: |
docker build \
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
--build-arg GITHUB_SHA=${{ github.sha }} \
--build-arg GITHUB_REF_NAME=${{ github.ref_name }} \
-f apps/client/Dockerfile \
-t ${{env.LOCATION}}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.REPO_NAME }}/client:${{ github.sha }}-${{ github.ref_name }} \
.
docker push ${{env.LOCATION}}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.REPO_NAME }}/client:${{ github.sha }}-${{ github.ref_name }}
- name: Deploy Client to Cloud Run
id: deploy-client
uses: google-github-actions/deploy-cloudrun@v2
with:
service: ${{ secrets.CLIENT_SERVICE }}
region: ${{env.LOCATION}}
image: ${{env.LOCATION}}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.REPO_NAME }}/client:${{ github.sha }}-${{ github.ref_name }}
env_vars: |
API_URL=${{ steps.deploy-server.outputs.url }}
flags: |
--port 80
--memory 256Mi
--cpu 1
--max-instances 3
--min-instances 1
--concurrency 100
--allow-unauthenticated
--ingress=all
--ingress=internal-and-cloud-load-balancing
timeout: 600s
3 changes: 2 additions & 1 deletion apps/client/src/environments/environment.prod.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export const environment = {
production: true,
apiUrl: typeof window !== 'undefined' ? window.location.origin + '/api/v1' : '${API_URL}/api/v1'
// apiUrl: typeof window !== 'undefined' ? window.location.origin + '/api/v1' : '${API_URL}/api/v1'
apiUrl: 'API_URL_PLACEHOLDER/api/v1'
};

0 comments on commit 41223e8

Please sign in to comment.