Skip to content

Commit

Permalink
fix deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
YassineKADER committed May 29, 2024
1 parent 87bb76d commit 5f7c9f6
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions .github/workflows/deployGcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy to Cloud Run

on:
push:
branches: ["main"]
branches: ["main","dev"]
pull_request:
branches: ["main"]

Expand All @@ -12,7 +12,6 @@ env:
SERVICE_NAME: bemyeyes-backend

jobs:

deploy:
name: Deploy to Cloud Run
runs-on: ubuntu-latest
Expand All @@ -22,25 +21,28 @@ jobs:
uses: actions/checkout@v3

- name: Google Auth
id: auth
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}

- name: Docker Auth
id: docker-auth
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCP_SA_KEY }}

- name: Build and Push Docker Image
run: |-
env:
PROJECT_ID: ${{ env.PROJECT_ID }}
SERVICE_NAME: ${{ env.SERVICE_NAME }}
GITHUB_SHA: ${{ github.sha }}
run: |
gcloud auth configure-docker
echo ${{ secrets.SERVICE_ACCOUNT_TRANSCRIPTION }} > gcp_service_account.json
echo ${{ secrets.ENV_FILE }} > .env
docker build -t gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}:${{ github.sha }} .
docker push gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}:${{ github.sha }}
docker build -t gcr.io/${PROJECT_ID}/${SERVICE_NAME}:${GITHUB_SHA} .
docker push gcr.io/${PROJECT_ID}/${SERVICE_NAME}:${GITHUB_SHA}
- name: Deploy to Cloud Run
run: |-
gcloud run deploy ${{ env.SERVICE_NAME }} --image gcr.io/${{ env.PROJECT_ID }}/${{ env.SERVICE_NAME }}:${{ github.sha }} --region ${{ env.GAR_LOCATION }} --port 3000
env:
PROJECT_ID: ${{ env.PROJECT_ID }}
SERVICE_NAME: ${{ env.SERVICE_NAME }}
GAR_LOCATION: ${{ env.GAR_LOCATION }}
GITHUB_SHA: ${{ github.sha }}
run: |
gcloud run deploy ${SERVICE_NAME} --image gcr.io/${PROJECT_ID}/${SERVICE_NAME}:${GITHUB_SHA} --region ${GAR_LOCATION} --port 3000

0 comments on commit 5f7c9f6

Please sign in to comment.