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 tests:
31 name: Run tests
32 runs-on:
33 - self-hosted
34 - test
35 needs: style
36 steps:
37 - name: Checkout repo
38 uses: actions/checkout@v4
39 with:
40 clean: false
41 submodules: "recursive"
42 fetch-depth: 0
43
44 - name: Run tests
45 uses: ./.github/actions/run_tests
46
47 publish:
48 name: Publish collab server image
49 needs:
50 - style
51 - tests
52 runs-on:
53 - self-hosted
54 - deploy
55 steps:
56 - name: Add Rust to the PATH
57 run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
58
59 - name: Sign into DigitalOcean docker registry
60 run: doctl registry login
61
62 - name: Prune Docker system
63 run: docker system prune --filter 'until=720h' -f
64
65 - name: Checkout repo
66 uses: actions/checkout@v4
67 with:
68 clean: false
69 submodules: "recursive"
70
71 - name: Build docker image
72 run: docker build . --build-arg GITHUB_SHA=$GITHUB_SHA --tag registry.digitalocean.com/zed/collab:$GITHUB_SHA
73
74 - name: Publish docker image
75 run: docker push registry.digitalocean.com/zed/collab:${GITHUB_SHA}
76
77 deploy:
78 name: Deploy new server image
79 needs:
80 - publish
81 runs-on:
82 - self-hosted
83 - deploy
84
85 steps:
86 - name: Sign into Kubernetes
87 run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.CLUSTER_NAME }}
88
89 - name: Determine namespace
90 run: |
91 set -eu
92 if [[ $GITHUB_REF_NAME = "collab-production" ]]; then
93 echo "Deploying collab:$GITHUB_SHA to production"
94 echo "KUBE_NAMESPACE=production" >> $GITHUB_ENV
95 elif [[ $GITHUB_REF_NAME = "collab-staging" ]]; then
96 echo "Deploying collab:$GITHUB_SHA to staging"
97 echo "KUBE_NAMESPACE=staging" >> $GITHUB_ENV
98 else
99 echo "cowardly refusing to deploy from an unknown branch"
100 exit 1
101 fi
102
103 - name: Start rollout
104 run: kubectl -n "$KUBE_NAMESPACE" set image deployment/collab collab=registry.digitalocean.com/zed/collab:${GITHUB_SHA}
105
106 - name: Wait for rollout to finish
107 run: kubectl -n "$KUBE_NAMESPACE" rollout status deployment/collab