Skip to content

Merge pull request #69 from FellasDevs/feat/actions #14

Merge pull request #69 from FellasDevs/feat/actions

Merge pull request #69 from FellasDevs/feat/actions #14

name: Build and Deploy to Cloud Run
on:
push:
branches: [ "main" ]
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
GAR_LOCATION: ${{ secrets.GAR_LOCATION }}
SERVICE: ${{ secrets.SERVICE_NAME }}
REGION: ${{ secrets.SERVICE_REGION }}
GCP_CREDENTIALS: ${{ secrets.GCP_CREDENTIALS }}
IMAGE_NAME: gcr.io/${{ secrets.PROJECT_ID }}/site:latest
jobs:
deploy:
runs-on: ubuntu-latest
permissions:
contents: 'read'
id-token: 'write'
steps:
- name: Checkout
uses: actions/checkout@v2
# Login to GCP
- uses: google-github-actions/setup-gcloud@v0.2.0
with:
service_account_key: ${{ env.GCP_CREDENTIALS }}
project_id: ${{ secrets.PROJECT_ID }}
# gcloud configure docker
- name: Configure Docker
run: gcloud auth configure-docker --quiet
# build image
- name: Build Docker image
run: docker build -t $IMAGE_NAME .
# push image to registry
- name: Push Docker image
run: docker push $IMAGE_NAME
# deploy image
- name: Deploy Docker image
run: gcloud run deploy site --image $IMAGE_NAME --region southamerica-east1 --memory 128Mi --min-instances 0 --max-instances 1 --platform managed --port 8080 --allow-unauthenticated