1name: Publish Collab Server Image
2
3on:
4 push:
5 tags:
6 - collab-production
7 - collab-staging
8
9env:
10 DOCKER_BUILDKIT: 1
11 DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
12
13jobs:
14 style:
15 name: Check formatting and Clippy lints
16 runs-on:
17 - self-hosted
18 - test
19 steps:
20 - name: Checkout repo
21 uses: actions/checkout@v4
22 with:
23 clean: false
24 submodules: "recursive"
25 fetch-depth: 0
26
27 - name: Run style checks
28 uses: ./.github/actions/check_style
29
30 - name: Run clippy
31 shell: bash -euxo pipefail {0}
32 run: script/clippy
33
34 tests:
35 name: Run tests
36 runs-on:
37 - self-hosted
38 - test
39 needs: style
40 steps:
41 - name: Checkout repo
42 uses: actions/checkout@v4
43 with:
44 clean: false
45 submodules: "recursive"
46 fetch-depth: 0
47
48 - name: Run tests
49 uses: ./.github/actions/run_tests
50
51 publish:
52 name: Publish collab server image
53 needs:
54 - style
55 - tests
56 runs-on:
57 - self-hosted
58 - deploy
59 steps:
60 - name: Add Rust to the PATH
61 run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
62
63 - name: Sign into DigitalOcean docker registry
64 run: doctl registry login
65
66 - name: Prune Docker system
67 run: docker system prune --filter 'until=720h' -f
68
69 - name: Checkout repo
70 uses: actions/checkout@v4
71 with:
72 clean: false
73 submodules: "recursive"
74
75 - name: Build docker image
76 run: docker build . --build-arg GITHUB_SHA=$GITHUB_SHA --tag registry.digitalocean.com/zed/collab:$GITHUB_SHA
77
78 - name: Publish docker image
79 run: docker push registry.digitalocean.com/zed/collab:${GITHUB_SHA}
80
81 deploy:
82 name: Deploy new server image
83 needs:
84 - publish
85 runs-on:
86 - self-hosted
87 - deploy
88
89 steps:
90 - name: Sign into Kubernetes
91 run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.CLUSTER_NAME }}
92
93 - name: Determine namespace
94 run: |
95 set -eu
96 if [[ $GITHUB_REF_NAME = "collab-production" ]]; then
97 echo "Deploying collab:$GITHUB_SHA to production"
98 echo "KUBE_NAMESPACE=production" >> $GITHUB_ENV
99 elif [[ $GITHUB_REF_NAME = "collab-staging" ]]; then
100 echo "Deploying collab:$GITHUB_SHA to staging"
101 echo "KUBE_NAMESPACE=staging" >> $GITHUB_ENV
102 else
103 echo "cowardly refusing to deploy from an unknown branch"
104 exit 1
105 fi
106
107 - name: Start rollout
108 run: kubectl -n "$KUBE_NAMESPACE" set image deployment/collab collab=registry.digitalocean.com/zed/collab:${GITHUB_SHA}
109
110 - name: Wait for rollout to finish
111 run: kubectl -n "$KUBE_NAMESPACE" rollout status deployment/collab