Modify deploy_chainlit.yml for main branch and API key #14
This file contains hidden or 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: 'Build and Deploy Chainlit Agent to Cloud Run' | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| env: | |
| PROJECT_ID: ${{ secrets.GCP_PROJECT_ID }} | |
| REGION: ${{ secrets.GCP_REGION }} | |
| SERVICE: agent-orchestre-finance | |
| AR_HOSTNAME: ${{ secrets.GCP_REGION }}-docker.pkg.dev | |
| AR_REPOSITORY: chainlit-images | |
| jobs: | |
| deploy: | |
| runs-on: 'ubuntu-latest' | |
| permissions: | |
| contents: 'read' | |
| id-token: 'write' | |
| steps: | |
| - name: 'Checkout Code' | |
| 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: 'Create Artifact Registry Repository' | |
| run: | | |
| gcloud artifacts repositories create ${{ env.AR_REPOSITORY }} \ | |
| --repository-format=docker \ | |
| --location=${{ env.REGION }} \ | |
| --description="Repository for Chainlit Agent Docker images" \ | |
| --async || true | |
| - name: 'Configure Docker to use Artifact Registry' | |
| run: gcloud auth configure-docker ${{ env.AR_HOSTNAME }} --quiet | |
| - name: 'Build and Push Container' | |
| id: build-image | |
| run: | | |
| IMAGE_TAG="${{ env.AR_HOSTNAME }}/${{ env.PROJECT_ID }}/${{ env.AR_REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}" | |
| echo "Building image: $IMAGE_TAG" | |
| docker build --tag "${IMAGE_TAG}" . | |
| docker push "${IMAGE_TAG}" | |
| echo "IMAGE_URL=${IMAGE_TAG}" >> $GITHUB_OUTPUT | |
| # DÉPLOIEMENT SUR CLOUD RUN | |
| - name: 'Deploy to Cloud Run' | |
| uses: 'google-github-actions/deploy-cloudrun@v2' | |
| with: | |
| service: '${{ env.SERVICE }}' | |
| region: '${{ env.REGION }}' | |
| image: '${{ steps.build-image.outputs.IMAGE_URL }}' | |
| env_vars: | | |
| OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }} | |
| TAVILY_API_KEY=${{ secrets.TAVILY_API_KEY }} | |
| OPENWEATHER_API_KEY=${{ secrets.OPENWEATHER_API_KEY }} | |
| flags: --allow-unauthenticated | |
| - name: 'Show output URL' | |
| run: | | |
| echo "Déploiement réussi ! URL du service:" | |
| echo "${{ steps.deploy.outputs.url }}" |