1+ name : ' Build and Deploy Chainlit Agent to Cloud Run'
2+
3+ on :
4+ push :
5+ branches :
6+ - branche-bintou
7+ workflow_dispatch :
8+
9+ env :
10+ PROJECT_ID : ${{ secrets.GCP_PROJECT_ID }}
11+ REGION : ${{ secrets.GCP_REGION }}
12+ SERVICE : agent-orchestre-finance
13+ AR_HOSTNAME : ${{ secrets.GCP_REGION }}-docker.pkg.dev
14+ AR_REPOSITORY : chainlit-images
15+
16+ jobs :
17+ deploy :
18+ runs-on : ' ubuntu-latest'
19+
20+ permissions :
21+ contents : ' read'
22+ id-token : ' write'
23+
24+ steps :
25+ - name : ' Checkout Code'
26+ uses : ' actions/checkout@v4'
27+
28+
29+ - id : ' auth'
30+ name : ' Authenticate to Google Cloud'
31+ uses : ' google-github-actions/auth@v2'
32+ with :
33+ credentials_json : ' ${{ secrets.GCP_SA_KEY }}'
34+
35+
36+ - name : ' Create Artifact Registry Repository'
37+ run : |
38+ gcloud artifacts repositories create ${{ env.AR_REPOSITORY }} \
39+ --repository-format=docker \
40+ --location=${{ env.REGION }} \
41+ --description="Repository for Chainlit Agent Docker images" \
42+ --async || true
43+
44+
45+ - name : ' Configure Docker to use Artifact Registry'
46+ run : gcloud auth configure-docker ${{ env.AR_HOSTNAME }} --quiet
47+
48+
49+ - name : ' Build and Push Container'
50+ id : build-image
51+ run : |
52+ IMAGE_TAG="${{ env.AR_HOSTNAME }}/${{ env.PROJECT_ID }}/${{ env.AR_REPOSITORY }}/${{ env.SERVICE }}:${{ github.sha }}"
53+
54+ echo "Building image: $IMAGE_TAG"
55+ docker build --tag "${IMAGE_TAG}" .
56+ docker push "${IMAGE_TAG}"
57+ echo "IMAGE_URL=${IMAGE_TAG}" >> $GITHUB_OUTPUT
58+
59+ # DÉPLOIEMENT SUR CLOUD RUN
60+ - name : ' Deploy to Cloud Run'
61+ uses : ' google-github-actions/deploy-cloudrun@v2'
62+ with :
63+ service : ' ${{ env.SERVICE }}'
64+ region : ' ${{ env.REGION }}'
65+ image : ' ${{ steps.build-image.outputs.IMAGE_URL }}'
66+ env_vars : |
67+ OPENAI_API_KEY=${{ secrets.OPENAI_API_KEY }}
68+ TAVILY_API_KEY=${{ secrets.TAVILY_API_KEY }}
69+ flags : --allow-unauthenticated
70+
71+ - name : ' Show output URL'
72+ run : |
73+ echo "Déploiement réussi ! URL du service:"
74+ echo "${{ steps.deploy.outputs.url }}"
0 commit comments