fix: CI/CD deploy #1
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: Deployment to the Google Cloud Platform run service | ||
on: [push, pull_request] | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.11 | ||
- name: Install dependencies | ||
run: | | ||
python -m venv venv | ||
. venv/bin/activate | ||
pip install black | ||
- name: Run black | ||
run: | | ||
. venv/bin/activate | ||
black --check . | ||
deploy: | ||
runs-on: ubuntu-latest | ||
needs: lint | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
- name: Set up GCP SDK | ||
uses: google-github-actions/setup-gcloud@v1 | ||
with: | ||
version: 'latest' | ||
service_account_key: ${{ secrets.GCP_SA_KEY }} | ||
project_id: ${{ secrets.GCP_PROJECT_ID }} | ||
- name: Configure Docker | ||
run: | | ||
gcloud auth configure-docker | ||
- name: Build with Google Cloud Build | ||
run: | | ||
gcloud builds submit --tag gcr.io/${{ secrets.GCP_PROJECT_ID }}/raight-move-backend:$GITHUB_SHA | ||
- name: Deploy to Cloud Run | ||
run: | | ||
gcloud run deploy raight-move-backend \ | ||
--image gcr.io/${{ secrets.GCP_PROJECT_ID }}/raight-move-backend:$GITHUB_SHA \ | ||
--platform managed \ | ||
--region ${{ secrets.GCP_REGION }} \ | ||
--allow-unauthenticated | ||