Update google-cloudrun-docker.yml #16
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
name: Build and Deploy to Cloud Run | |
on: | |
push: | |
branches: | |
- main # Trigger on pushes to the 'main' branch | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout the repository | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
# Authenticate to Google Cloud using Service Account Key | |
- name: Authenticate to Google Cloud | |
uses: google-github-actions/auth@v1 | |
with: | |
credentials_json: ${{ secrets.GCP_SA_KEY }} # Service Account Key stored in GitHub Secrets | |
# Set up Google Cloud SDK | |
- name: Set up Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
version: 'latest' | |
# Configure Docker to use Google Artifact Registry | |
- name: Configure Docker for Artifact Registry | |
run: gcloud auth configure-docker us-west1-docker.pkg.dev | |
# Build the Docker image | |
- name: Build Docker image | |
run: | | |
DOCKER_TAG="us-west1-docker.pkg.dev/legalqaapp/legalappgh2/legalappgh2:${{ github.sha }}" | |
docker build -t "${DOCKER_TAG}" . | |
# Push the Docker image to Google Artifact Registry | |
- name: Push Docker image to Artifact Registry | |
run: | | |
DOCKER_TAG="us-west1-docker.pkg.dev/legalqaapp/legalappgh2/legalappgh2:${{ github.sha }}" | |
docker push "${DOCKER_TAG}" | |
# Deploy the Docker image to Google Cloud Run | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy legalappgh \ | |
--image us-west1-docker.pkg.dev/legalqaapp/legalappgh2/legalappgh2:${{ github.sha }} \ | |
--platform managed \ | |
--region us-west1 \ | |
--allow-unauthenticated \ | |
--port 8000 | |
# Show the output URL of the deployed service | |
- name: Show output | |
run: echo ${{ steps.deploy.outputs.url }} |