GCP Deployment #142
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: GCP Deployment | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- '**.py' | |
- 'requirements.txt' | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- id: 'auth' | |
name: 'Authenticate to Google Cloud' | |
uses: 'google-github-actions/auth@v1' | |
with: | |
credentials_json: ${{ secrets.GCP_SA_KEY }} | |
- name: Setup Cloud SDK | |
uses: google-github-actions/setup-gcloud@v1 | |
with: | |
project_id: ${{ secrets.GCP_PROJECT_ID }} | |
# Check if the bucket exists and delete it | |
- name: Delete Existing Bucket | |
run: | | |
if gsutil ls "gs://$GCS_BUCKET_NAME"; then | |
gsutil -m rm -r "gs://$GCS_BUCKET_NAME" | |
fi | |
env: | |
GCS_BUCKET_NAME: ${{ secrets.GCS_BUCKET_NAME }} | |
# Create a new bucket | |
- name: Create New GCS Bucket | |
run: gsutil mb "gs://$GCS_BUCKET_NAME" | |
env: | |
GCS_BUCKET_NAME: ${{ secrets.GCS_BUCKET_NAME }} | |
- run: gcloud functions deploy ${{ secrets.GCP_FUNCTION }} --runtime python311 --memory 512MB --timeout 120s --trigger-http --allow-unauthenticated --entry-point process_event --region ${{ secrets.GCP_REGION }} --set-env-vars GCP_SA_KEY=${{ secrets.GCP_SA_KEY }},GCS_BUCKET_NAME=${{ secrets.GCS_BUCKET_NAME }},OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }},MODEL_NAME=${{ secrets.MODEL_NAME }},SYSTEM_PROMPT="${{ secrets.SYSTEM_PROMPT }}",MAX_TURNS="${{ secrets.MAX_TURNS }}",TTL="${{ secrets.TTL }}",MAX_TOKENS_INPUT="${{ secrets.MAX_TOKENS_INPUT }}",MAX_TOKENS_OUTPUT="${{ secrets.MAX_TOKENS_OUTPUT }}",TEMPERATURE="${{ secrets.TEMPERATURE }}",IMAGE_SIZE="${{ secrets.IMAGE_SIZE }}",IMAGE_STYLE="${{ secrets.IMAGE_STYLE}}",IMAGE_QUALITY="${{ secrets.IMAGE_QUALITY }}",DALLE_MODEL="${{ secrets.DALLE_MODEL }}",ELEVENLABS_API_KEY="${{ secrets.ELEVENLABS_API_KEY }}",ELEVENLABS_MODEL_NAME="${{ secrets.ELEVENLABS_MODEL_NAME }}" |