Update bot.py #6
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 to Cloud Run | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
SERVICE_NAME: discord-bot | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: 'read' | |
id-token: 'write' | |
steps: | |
- uses: actions/checkout@v4 | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v2' | |
with: | |
credentials_json: '${{ secrets.GCP_SA_KEY }}' | |
- name: 'Set up Cloud SDK' | |
uses: 'google-github-actions/setup-gcloud@v2' | |
- name: Configure Docker | |
run: gcloud auth configure-docker | |
- name: Build and Push Docker image | |
run: | | |
echo "Building image for project: $PROJECT_ID" | |
docker build -t gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }} ./bot | |
docker push gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }} | |
- name: Deploy to Cloud Run | |
run: | | |
gcloud run deploy $SERVICE_NAME \ | |
--image gcr.io/$PROJECT_ID/$SERVICE_NAME:${{ github.sha }} \ | |
--platform managed \ | |
--region asia-south1 \ | |
--allow-unauthenticated \ | |
--set-env-vars="DISCORD_TOKEN=${{ secrets.DISCORD_TOKEN }},RESEND_API_KEY=${{ secrets.RESEND_API_KEY }},UPSTASH_REDIS_REST_URL=${{ secrets.UPSTASH_REDIS_REST_URL }},UPSTASH_REDIS_REST_TOKEN=${{ secrets.UPSTASH_REDIS_REST_TOKEN }}" |