2024-02-01 18:54:49 +00:00
|
|
|
name: Publish Collab Server Image
|
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
tags:
|
|
|
|
- collab-production
|
|
|
|
- collab-staging
|
|
|
|
|
|
|
|
env:
|
|
|
|
DOCKER_BUILDKIT: 1
|
|
|
|
DIGITALOCEAN_ACCESS_TOKEN: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
style:
|
|
|
|
name: Check formatting and Clippy lints
|
|
|
|
runs-on:
|
|
|
|
- self-hosted
|
|
|
|
- test
|
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
clean: false
|
|
|
|
fetch-depth: 0
|
|
|
|
|
|
|
|
- name: Run style checks
|
|
|
|
uses: ./.github/actions/check_style
|
|
|
|
|
2024-02-08 20:56:29 +00:00
|
|
|
- name: Run clippy
|
2024-06-18 19:49:44 +00:00
|
|
|
run: ./script/clippy
|
2024-02-08 20:56:29 +00:00
|
|
|
|
2024-02-01 18:54:49 +00:00
|
|
|
tests:
|
|
|
|
name: Run tests
|
|
|
|
runs-on:
|
|
|
|
- self-hosted
|
|
|
|
- test
|
|
|
|
needs: style
|
|
|
|
steps:
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
clean: false
|
|
|
|
fetch-depth: 0
|
|
|
|
|
2024-02-15 20:53:57 +00:00
|
|
|
- name: Install cargo nextest
|
|
|
|
shell: bash -euxo pipefail {0}
|
|
|
|
run: |
|
|
|
|
cargo install cargo-nextest
|
|
|
|
|
|
|
|
- name: Limit target directory size
|
|
|
|
shell: bash -euxo pipefail {0}
|
|
|
|
run: script/clear-target-dir-if-larger-than 100
|
|
|
|
|
2024-02-01 18:54:49 +00:00
|
|
|
- name: Run tests
|
2024-02-15 20:53:57 +00:00
|
|
|
shell: bash -euxo pipefail {0}
|
|
|
|
run: cargo nextest run --package collab --no-fail-fast
|
2024-02-01 18:54:49 +00:00
|
|
|
|
|
|
|
publish:
|
|
|
|
name: Publish collab server image
|
|
|
|
needs:
|
|
|
|
- style
|
|
|
|
- tests
|
|
|
|
runs-on:
|
|
|
|
- self-hosted
|
|
|
|
- deploy
|
|
|
|
steps:
|
|
|
|
- name: Add Rust to the PATH
|
|
|
|
run: echo "$HOME/.cargo/bin" >> $GITHUB_PATH
|
|
|
|
|
|
|
|
- name: Sign into DigitalOcean docker registry
|
|
|
|
run: doctl registry login
|
|
|
|
|
|
|
|
- name: Checkout repo
|
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
clean: false
|
|
|
|
|
2024-06-14 22:15:13 +00:00
|
|
|
- name: Set up default .cargo/config.toml
|
2024-06-14 22:36:48 +00:00
|
|
|
run: cp ./.cargo/collab-config.toml ./.cargo/config.toml
|
2024-06-14 22:15:13 +00:00
|
|
|
|
2024-02-01 18:54:49 +00:00
|
|
|
- name: Build docker image
|
|
|
|
run: docker build . --build-arg GITHUB_SHA=$GITHUB_SHA --tag registry.digitalocean.com/zed/collab:$GITHUB_SHA
|
|
|
|
|
|
|
|
- name: Publish docker image
|
|
|
|
run: docker push registry.digitalocean.com/zed/collab:${GITHUB_SHA}
|
|
|
|
|
2024-02-14 22:11:57 +00:00
|
|
|
- name: Prune Docker system
|
|
|
|
run: docker system prune --filter 'until=72h' -f
|
|
|
|
|
2024-02-01 18:54:49 +00:00
|
|
|
deploy:
|
|
|
|
name: Deploy new server image
|
|
|
|
needs:
|
|
|
|
- publish
|
|
|
|
runs-on:
|
|
|
|
- self-hosted
|
|
|
|
- deploy
|
|
|
|
|
|
|
|
steps:
|
|
|
|
- name: Sign into Kubernetes
|
|
|
|
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ secrets.CLUSTER_NAME }}
|
|
|
|
|
2024-02-15 20:53:57 +00:00
|
|
|
- name: Start rollout
|
2024-02-01 18:54:49 +00:00
|
|
|
run: |
|
|
|
|
set -eu
|
|
|
|
if [[ $GITHUB_REF_NAME = "collab-production" ]]; then
|
2024-02-15 20:53:57 +00:00
|
|
|
export ZED_KUBE_NAMESPACE=production
|
2024-03-06 09:38:17 +00:00
|
|
|
export ZED_COLLAB_LOAD_BALANCER_SIZE_UNIT=10
|
|
|
|
export ZED_API_LOAD_BALANCER_SIZE_UNIT=2
|
2024-02-01 18:54:49 +00:00
|
|
|
elif [[ $GITHUB_REF_NAME = "collab-staging" ]]; then
|
2024-02-15 20:53:57 +00:00
|
|
|
export ZED_KUBE_NAMESPACE=staging
|
2024-03-06 09:38:17 +00:00
|
|
|
export ZED_COLLAB_LOAD_BALANCER_SIZE_UNIT=1
|
|
|
|
export ZED_API_LOAD_BALANCER_SIZE_UNIT=1
|
2024-02-01 18:54:49 +00:00
|
|
|
else
|
|
|
|
echo "cowardly refusing to deploy from an unknown branch"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-02-15 20:53:57 +00:00
|
|
|
echo "Deploying collab:$GITHUB_SHA to $ZED_KUBE_NAMESPACE"
|
|
|
|
|
|
|
|
source script/lib/deploy-helpers.sh
|
|
|
|
export_vars_for_environment $ZED_KUBE_NAMESPACE
|
|
|
|
|
|
|
|
export ZED_DO_CERTIFICATE_ID=$(doctl compute certificate list --format ID --no-header)
|
|
|
|
export ZED_IMAGE_ID="registry.digitalocean.com/zed/collab:${GITHUB_SHA}"
|
2024-02-01 18:54:49 +00:00
|
|
|
|
2024-02-23 17:14:40 +00:00
|
|
|
export ZED_SERVICE_NAME=collab
|
2024-03-06 10:03:14 +00:00
|
|
|
export ZED_LOAD_BALANCER_SIZE_UNIT=$ZED_COLLAB_LOAD_BALANCER_SIZE_UNIT
|
2024-02-15 20:53:57 +00:00
|
|
|
envsubst < crates/collab/k8s/collab.template.yml | kubectl apply -f -
|
2024-02-23 17:14:40 +00:00
|
|
|
kubectl -n "$ZED_KUBE_NAMESPACE" rollout status deployment/$ZED_SERVICE_NAME --watch
|
|
|
|
echo "deployed ${ZED_SERVICE_NAME} to ${ZED_KUBE_NAMESPACE}"
|
|
|
|
|
|
|
|
export ZED_SERVICE_NAME=api
|
2024-03-06 10:03:14 +00:00
|
|
|
export ZED_LOAD_BALANCER_SIZE_UNIT=$ZED_API_LOAD_BALANCER_SIZE_UNIT
|
2024-02-23 17:14:40 +00:00
|
|
|
envsubst < crates/collab/k8s/collab.template.yml | kubectl apply -f -
|
|
|
|
kubectl -n "$ZED_KUBE_NAMESPACE" rollout status deployment/$ZED_SERVICE_NAME --watch
|
|
|
|
echo "deployed ${ZED_SERVICE_NAME} to ${ZED_KUBE_NAMESPACE}"
|