Deploy Connectors #1198
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 Connectors | |
on: | |
workflow_dispatch: | |
concurrency: | |
group: deploy_connectors | |
cancel-in-progress: false | |
env: | |
GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }} | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Get short sha | |
id: short_sha | |
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Initiate a deployment | |
id: build_message | |
uses: slackapi/[email protected] | |
with: | |
method: chat.postMessage | |
token: ${{ secrets.SLACK_BOT_TOKEN }} | |
payload: | | |
channel: ${{ secrets.SLACK_CHANNEL_ID }} | |
text: | | |
🚀 Starting deployment of connectors `${{ steps.short_sha.outputs.short_sha }}` | |
• Commit: <${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ steps.short_sha.outputs.short_sha }}> | |
• Workflow: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View build> | |
• Author: ${{ github.actor }} | |
Building image... | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} | |
- name: "Authenticate with Google Cloud" | |
uses: "google-github-actions/auth@v1" | |
with: | |
credentials_json: "${{ secrets.GCLOUD_SA_KEY }}" | |
- name: "Set up Cloud SDK" | |
uses: "google-github-actions/setup-gcloud@v1" | |
- name: Build the image on Cloud Build | |
run: | | |
chmod +x ./k8s/cloud-build.sh | |
./k8s/cloud-build.sh \ | |
--image-name=connectors \ | |
--dockerfile-path=./connectors/Dockerfile \ | |
--working-dir=./ \ | |
--dust-client-facing-url=https://dust.tt | |
- name: Notify Deploy Start | |
id: deployment_message | |
uses: slackapi/[email protected] | |
with: | |
method: chat.postMessage | |
token: ${{ secrets.SLACK_BOT_TOKEN }} | |
payload: | | |
channel: ${{ secrets.SLACK_CHANNEL_ID }} | |
thread_ts: "${{ steps.build_message.outputs.ts }}" | |
text: | | |
✅ Image build completed | |
Starting deployment to regions: us-central1 | |
- name: Generate a token | |
id: generate-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: ${{ secrets.INFRA_DISPATCH_APP_ID }} | |
private-key: ${{ secrets.INFRA_DISPATCH_APP_PRIVATE_KEY }} | |
owner: ${{ github.repository_owner }} | |
repositories: | | |
dust-infra | |
- name: Trigger dust-infra workflow | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{ steps.generate-token.outputs.token }} | |
script: | | |
await github.rest.repos.createDispatchEvent({ | |
owner: '${{ github.repository_owner }}', | |
repo: 'dust-infra', | |
event_type: 'trigger-component-deploy', | |
client_payload: { | |
regions: 'us-central1', | |
component: 'connectors', | |
image_tag: '${{ steps.short_sha.outputs.short_sha }}', | |
slack_thread_ts: "${{ steps.build_message.outputs.ts }}", | |
slack_channel: '${{ secrets.SLACK_CHANNEL_ID }}' | |
} | |
}); | |
- name: Notify Failure | |
if: failure() | |
uses: slackapi/[email protected] | |
with: | |
method: chat.postMessage | |
token: ${{ secrets.SLACK_BOT_TOKEN }} | |
payload: | | |
channel: ${{ secrets.SLACK_CHANNEL_ID }} | |
thread_ts: "${{ steps.build_message.outputs.ts }}" | |
text: | | |
❌ Build pipeline failed | |
Check the workflow logs: <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View logs> |