cicd try5 #6
This file contains hidden or 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 React App to Cloud Run | |
on: | |
push: | |
branches: [react-portfolio] | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v2 | |
with: | |
credentials_json: ${{ secrets.GCP_SA_KEY }} | |
- name: Set up gcloud CLI | |
uses: google-github-actions/setup-gcloud@v2 | |
with: | |
project_id: personalhub3 | |
- name: Configure Docker for Artifact Registry | |
run: gcloud auth configure-docker us-docker.pkg.dev | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: ./react_app | |
push: true | |
tags: us-central1-docker.pkg.dev/personalhub3/personalhub-artifact-repo/portfolio-app:latest | |
# - name: Build and Push Docker Image | |
# run: | | |
# docker build -t us-central1-docker.pkg.dev/personalhub3/personalhub-artifact-repo/portfolio-app:latest ./react_app | |
# docker push us-central1-docker.pkg.dev/personalhub3/personalhub-artifact-repo/portfolio-app:latest | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy personalhub-run-portfolio \ | |
--image=us-central1-docker.pkg.dev/personalhub3/personalhub-artifact-repo/portfolio-app:latest \ | |
--platform=managed \ | |
--region=us-central1 \ | |
--allow-unauthenticated |