modified yaml #4
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: Deploy Savemoney API to Cloud Run | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set Up Cloud SDK | |
uses: google-github-actions/[email protected] | |
with: | |
project_id: savemoney-capstone | |
service_account_key: ${{secrets.GCLOUD_AUTH}} | |
- name: Configure Docker to use gcloud | |
run: | | |
gcloud auth configure-docker asia-southeast1-docker.pkg.dev --quiet | |
- name: Set Environment Variables | |
run: | | |
echo "NODE_ENV=${{ secrets.NODE_ENV }}" >> $GITHUB_ENV | |
echo "DB_USERNAME=${{ secrets.DB_USERNAME }}" >> $GITHUB_ENV | |
# Add other secrets similarly | |
- name: Build and Push Docker Image | |
run: | | |
export IMAGE_TAG=$(git rev-parse --short ${{github.sha}}) | |
export IMAGE_NAME=asia-southeast1-docker.pkg.dev/savemoney-capstone/savemoney-api:${IMAGE_TAG} | |
# Docker build and push commands | |
- name: Deploy to Cloud Run | |
run: | | |
export IMAGE_TAG=$(git rev-parse --short ${{github.sha}}) | |
export IMAGE_NAME=asia-southeast1-docker.pkg.dev/savemoney-capstone/savemoney-api:${IMAGE_TAG} | |
gcloud run deploy savemoney-api --image ${IMAGE_NAME} --region asia-southeast1 --allow-unauthenticated |