ci : updates #14
Workflow file for this run
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: 🏓 backend-cd | |
# on: | |
# push: | |
# branches: | |
# - main | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
defaults: | |
run: | |
working-directory: ./backend | |
env: | |
REGION: ${{ secrets.REGION }} | |
REPO_NAME: ${{ secrets.REPO_NAME }} | |
SERVICE_NAME : ${{ secrets.SERVICE_NAME }} | |
CONTAINER_NAME: ${{ secrets.CONTAINER_NAME }} | |
jobs: | |
backend-deploy: | |
name: 🚀 Deploy to production | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out Git repository | |
uses: actions/checkout@v3 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: arunavabasu03 | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Login to GCP | |
uses: "google-github-actions/auth@v2" | |
with: | |
project_id: ${{ secrets.PROJECT_ID }} | |
credentials_json: "${{ secrets.CLOUD_RUN_SERVICE_ACCOUNT }}" | |
- name: Set up Cloud SDK | |
uses: "google-github-actions/setup-gcloud@v2" | |
- name: Build Docker image | |
run: | | |
docker build -t $CONTAINER_NAME:${{ github.sha }} -t $CONTAINER_NAME:latest . | |
- name: Push Docker image | |
run: | | |
docker push $CONTAINER_NAME:${{ github.sha }} && docker push $CONTAINER_NAME:latest | |
# - name: Deploy to Cloud Run | |
# run: | | |
# gcloud run deploy $SERVICE_NAME \ | |
# --image $CONTAINER_NAME:latest \ | |
# --platform managed \ | |
# --project $REPO_NAME \ | |
# --region $REGION | |
# --quiet | |
- name: Deploy to cloud run | |
uses: 'google-github-actions/deploy-cloudrun@v2' | |
with: | |
service: $SERVICE_NAME | |
image: $CONTAINER_NAME:latest | |
- name: 'Use output' | |
run: 'curl "${{ steps.deploy.outputs.url }}"' | |