Skip to content

Commit 2f6252f

Browse files
authored
[.github] - infra: new connectors deploy workflow (#8661)
* [.github] - feature: add manual workflow dispatch for deploying infrastructure - Introduce workflow_dispatch trigger with a configurable input for deploying to the 'us-central1' region - Implement concurrency control to manage deployment processes and prevent collisions - Authenticate with Google Cloud and set up the Cloud SDK for deployment tasks - Build a Docker image using Cloud Build and a custom script, with parameters for image name and Dockerfile path - Generate a GitHub App token dynamically for use in the workflow - Enable triggering of a downstream repository's workflow using a repository dispatch event with a custom payload including the region and image tag * [.github] - fix: update secrets and app ID for connector infra deployment - Switch to using specific app ID and private key for infra deployment - Correct the environment variable used for the GitHub token in the dispatch event trigger * [.github] - fix: correct working directory path in GitHub Actions config - Ensure the `cloud-build.sh` script uses the correct relative working directory by adding a leading `./` to the path configuration * [.github] - fix: use secret for INFRA_DISPATCH_APP_ID in GitHub Actions - Changed the GitHub App ID reference to use secrets for enhanced security and better management of sensitive data - This update ensures that the App ID is not exposed in the workflow file, aligning with best practices for credential storage
1 parent 131ed14 commit 2f6252f

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Deploy Infra
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
us-central1:
7+
description: "Deploy to us-central1"
8+
type: boolean
9+
default: true
10+
11+
concurrency:
12+
group: deploy_infra
13+
cancel-in-progress: false
14+
15+
env:
16+
GCLOUD_PROJECT_ID: ${{ secrets.GCLOUD_PROJECT_ID }}
17+
18+
jobs:
19+
build-and-deploy:
20+
runs-on: ubuntu-latest
21+
22+
if: github.ref == 'refs/heads/main'
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v3
27+
28+
- name: Get short sha
29+
id: short_sha
30+
run: echo "short_sha=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
31+
32+
- name: "Authenticate with Google Cloud"
33+
uses: "google-github-actions/auth@v1"
34+
with:
35+
credentials_json: "${{ secrets.GCLOUD_SA_KEY }}"
36+
37+
- name: "Set up Cloud SDK"
38+
uses: "google-github-actions/setup-gcloud@v1"
39+
40+
- name: Build the image on Cloud Build
41+
run: |
42+
chmod +x ./k8s/cloud-build.sh
43+
./k8s/cloud-build.sh \
44+
--image-name=connectors \
45+
--dockerfile-path=./connectors/Dockerfile \
46+
--working-dir=./ \
47+
--dust-client-facing-url=https://dust.tt
48+
49+
- name: Generate a token
50+
id: generate-token
51+
uses: actions/create-github-app-token@v1
52+
with:
53+
app-id: ${{ secrets.INFRA_DISPATCH_APP_ID }}
54+
private-key: ${{ secrets.INFRA_DISPATCH_APP_PRIVATE_KEY }}
55+
56+
- name: Trigger dust-infra workflow
57+
uses: actions/github-script@v6
58+
env:
59+
GH_TOKEN: ${{ steps.generate-token.outputs.token }}
60+
with:
61+
github-token: ${{ env.GH_TOKEN }}
62+
script: |
63+
await github.rest.repos.createDispatchEvent({
64+
owner: 'dust-tt',
65+
repo: 'dust-infra',
66+
event_type: 'trigger-component-deploy',
67+
client_payload: {
68+
us_central1: ${{ inputs.us-central1 }},
69+
component: 'connectors',
70+
image_tag: '${{ steps.short_sha.outputs.short_sha }}'
71+
}
72+
});

0 commit comments

Comments
 (0)