1name: Publish Collab Server Image
2
3on:
4 push:
5 tags:
6 - collab-production
7 - collab-staging
8
9env:
10 DOCKER_BUILDKIT: 1
11
12jobs:
13 style:
14 name: Check formatting and Clippy lints
15 runs-on:
16 - self-hosted
17 - test
18 steps:
19 - name: Checkout repo
20 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
21 with:
22 clean: false
23 fetch-depth: 0
24
25 - name: Run style checks
26 uses: ./.github/actions/check_style
27
28 - name: Run clippy
29 run: ./script/clippy
30
31 tests:
32 name: Run tests
33 runs-on:
34 - self-hosted
35 - test
36 needs: style
37 steps:
38 - name: Checkout repo
39 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
40 with:
41 clean: false
42 fetch-depth: 0
43
44 - name: Install cargo nextest
45 shell: bash -euxo pipefail {0}
46 run: |
47 cargo install cargo-nextest
48
49 - name: Limit target directory size
50 shell: bash -euxo pipefail {0}
51 run: script/clear-target-dir-if-larger-than 100
52
53 - name: Run tests
54 shell: bash -euxo pipefail {0}
55 run: cargo nextest run --package collab --no-fail-fast
56
57 publish:
58 name: Publish collab server image
59 needs:
60 - style
61 - tests
62 runs-on:
63 - buildjet-16vcpu-ubuntu-2204
64 steps:
65 - name: Install doctl
66 uses: digitalocean/action-doctl@v2
67 with:
68 token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
69
70 - name: Sign into DigitalOcean docker registry
71 run: doctl registry login
72
73 - name: Checkout repo
74 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
75 with:
76 clean: false
77
78 - name: Build docker image
79 run: |
80 docker build -f Dockerfile-collab \
81 --build-arg GITHUB_SHA=$GITHUB_SHA \
82 --tag registry.digitalocean.com/zed/collab:$GITHUB_SHA \
83 .
84
85 - name: Publish docker image
86 run: docker push registry.digitalocean.com/zed/collab:${GITHUB_SHA}
87
88 - name: Prune Docker system
89 run: docker system prune --filter 'until=72h' -f
90
91 deploy:
92 name: Deploy new server image
93 needs:
94 - publish
95 runs-on:
96 - buildjet-16vcpu-ubuntu-2204
97
98 steps:
99 - name: Checkout repo
100 uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
101 with:
102 clean: false
103
104 - name: Install doctl
105 uses: digitalocean/action-doctl@v2
106 with:
107 token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
108
109 - name: Sign into Kubernetes
110 run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.CLUSTER_NAME }}
111
112 - name: Start rollout
113 run: |
114 set -eu
115 if [[ $GITHUB_REF_NAME = "collab-production" ]]; then
116 export ZED_KUBE_NAMESPACE=production
117 export ZED_COLLAB_LOAD_BALANCER_SIZE_UNIT=10
118 export ZED_API_LOAD_BALANCER_SIZE_UNIT=2
119 export ZED_LLM_LOAD_BALANCER_SIZE_UNIT=2
120 elif [[ $GITHUB_REF_NAME = "collab-staging" ]]; then
121 export ZED_KUBE_NAMESPACE=staging
122 export ZED_COLLAB_LOAD_BALANCER_SIZE_UNIT=1
123 export ZED_API_LOAD_BALANCER_SIZE_UNIT=1
124 export ZED_LLM_LOAD_BALANCER_SIZE_UNIT=1
125 else
126 echo "cowardly refusing to deploy from an unknown branch"
127 exit 1
128 fi
129
130 echo "Deploying collab:$GITHUB_SHA to $ZED_KUBE_NAMESPACE"
131
132 source script/lib/deploy-helpers.sh
133 export_vars_for_environment $ZED_KUBE_NAMESPACE
134
135 export ZED_DO_CERTIFICATE_ID=$(doctl compute certificate list --format ID --no-header)
136 export ZED_IMAGE_ID="registry.digitalocean.com/zed/collab:${GITHUB_SHA}"
137
138 export ZED_SERVICE_NAME=collab
139 export ZED_LOAD_BALANCER_SIZE_UNIT=$ZED_COLLAB_LOAD_BALANCER_SIZE_UNIT
140 envsubst < crates/collab/k8s/collab.template.yml | kubectl apply -f -
141 kubectl -n "$ZED_KUBE_NAMESPACE" rollout status deployment/$ZED_SERVICE_NAME --watch
142 echo "deployed ${ZED_SERVICE_NAME} to ${ZED_KUBE_NAMESPACE}"
143
144 export ZED_SERVICE_NAME=api
145 export ZED_LOAD_BALANCER_SIZE_UNIT=$ZED_API_LOAD_BALANCER_SIZE_UNIT
146 envsubst < crates/collab/k8s/collab.template.yml | kubectl apply -f -
147 kubectl -n "$ZED_KUBE_NAMESPACE" rollout status deployment/$ZED_SERVICE_NAME --watch
148 echo "deployed ${ZED_SERVICE_NAME} to ${ZED_KUBE_NAMESPACE}"
149
150 export ZED_SERVICE_NAME=llm
151 export ZED_LOAD_BALANCER_SIZE_UNIT=$ZED_LLM_LOAD_BALANCER_SIZE_UNIT
152 envsubst < crates/collab/k8s/collab.template.yml | kubectl apply -f -
153 kubectl -n "$ZED_KUBE_NAMESPACE" rollout status deployment/$ZED_SERVICE_NAME --watch
154 echo "deployed ${ZED_SERVICE_NAME} to ${ZED_KUBE_NAMESPACE}"