Skip to content

Merge pull request #49 from RuffByte/KL-36-Add-Color-Preview #55

Merge pull request #49 from RuffByte/KL-36-Add-Color-Preview

Merge pull request #49 from RuffByte/KL-36-Add-Color-Preview #55

name: Build and Deploy to Cloud Run
on:
push:
branches:
- master
jobs:
deploy:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
environment: GCR
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
GAR_LOCATION: ${{ secrets.GAR_LOCATION }}
REPOSITORY: ${{ secrets.REPOSITORY }}
SERVICE: keylabs
REGION: ${{ secrets.GAR_LOCATION }}
DATABASE_URL: ${{secrets.DATABASE_URL}}
DIRECT_URL: ${{secrets.DIRECT_URL}}
GOOGLE_CLIENT_ID: ${{secrets.GOOGLE_CLIENT_ID}}
GOOGLE_CLIENT_SECRET: ${{secrets.GOOGLE_CLIENT_SECRET}}
NEXT_PUBLIC_URL: ${{secrets.NEXT_PUBLIC_URL}}
RESEND_API_KEY: ${{secrets.RESEND_API_KEY}}
EMAIL_FROM: ${{secrets.EMAIL_FROM}}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Google Auth
id: auth
uses: 'google-github-actions/auth@v2'
with:
credentials_json: '${{ secrets.GCP_CREDENTIALS }}'
token_format: 'access_token'
- name: Docker Auth
run: |-
gcloud auth configure-docker "${{ env.GAR_LOCATION }}-docker.pkg.dev"
- name: Build and Push Container
run: |-
docker build -t "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" ./
docker push "${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
- name: Deploy to Cloud Run
run: |-
gcloud run deploy ${{ env.SERVICE }} \
--image=${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }} \
--region=${{ env.REGION }} \
--max-instances=3 \
--platform=managed \
--allow-unauthenticated \
--set-env-vars PROJECT_ID=${{secrets.PROJECT_ID}},GAR_LOCATION=${{secrets.GAR_LOCATION}},REPOSITORY=${{secrets.REPOSITORY}},SERVICE=keylabs,REGION=${{secrets.GAR_LOCATION}},DATABASE_URL=${{secrets.DATABASE_URL}},DIRECT_URL=${{secrets.DIRECT_URL}},GOOGLE_CLIENT_ID=${{secrets.GOOGLE_CLIENT_ID}},GOOGLE_CLIENT_SECRET=${{secrets.GOOGLE_CLIENT_SECRET}},NEXT_PUBLIC_URL=${{secrets.NEXT_PUBLIC_URL}},RESEND_API_KEY=${{secrets.RESEND_API_KEY}},EMAIL_FROM="KeyLabs <noreply@keylabs.app>"
- name: Show Output
run: echo "Deployment completed"