Skip to content

Commit 15875a7

Browse files
authored
chore: add new deploy job for new dogfood (#10852)
1 parent 9ad9628 commit 15875a7

File tree

3 files changed

+184
-114
lines changed

3 files changed

+184
-114
lines changed

.github/workflows/ci.yaml

Lines changed: 176 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -389,100 +389,6 @@ jobs:
389389
with:
390390
api-key: ${{ secrets.DATADOG_API_KEY }}
391391

392-
deploy:
393-
name: "deploy"
394-
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
395-
timeout-minutes: 30
396-
needs: changes
397-
if: |
398-
github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
399-
&& needs.changes.outputs.docs-only == 'false'
400-
permissions:
401-
contents: read
402-
id-token: write
403-
steps:
404-
- name: Checkout
405-
uses: actions/checkout@v4
406-
with:
407-
fetch-depth: 0
408-
409-
- name: Authenticate to Google Cloud
410-
uses: google-github-actions/auth@v1
411-
with:
412-
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
413-
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com
414-
415-
- name: Set up Google Cloud SDK
416-
uses: google-github-actions/setup-gcloud@v1
417-
418-
- name: Setup Node
419-
uses: ./.github/actions/setup-node
420-
421-
- name: Setup Go
422-
uses: ./.github/actions/setup-go
423-
424-
- name: Install goimports
425-
run: go install golang.org/x/tools/cmd/goimports@latest
426-
- name: Install nfpm
427-
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
428-
429-
- name: Install zstd
430-
run: sudo apt-get install -y zstd
431-
432-
- name: Build Release
433-
run: |
434-
set -euo pipefail
435-
go mod download
436-
437-
version="$(./scripts/version.sh)"
438-
make gen/mark-fresh
439-
make -j \
440-
build/coder_"$version"_windows_amd64.zip \
441-
build/coder_"$version"_linux_amd64.{tar.gz,deb}
442-
443-
- name: Install Release
444-
run: |
445-
set -euo pipefail
446-
447-
regions=(
448-
# gcp-region-id instance-name systemd-service-name
449-
"us-central1-a coder coder"
450-
"australia-southeast1-b coder-sydney coder-workspace-proxy"
451-
"europe-west3-c coder-europe coder-workspace-proxy"
452-
"southamerica-east1-b coder-brazil coder-workspace-proxy"
453-
)
454-
455-
deb_pkg="./build/coder_$(./scripts/version.sh)_linux_amd64.deb"
456-
if [ ! -f "$deb_pkg" ]; then
457-
echo "deb package not found: $deb_pkg"
458-
ls -l ./build
459-
exit 1
460-
fi
461-
462-
gcloud config set project coder-dogfood
463-
for region in "${regions[@]}"; do
464-
echo "::group::$region"
465-
set -- $region
466-
467-
set -x
468-
gcloud config set compute/zone "$1"
469-
gcloud compute scp "$deb_pkg" "${2}:/tmp/coder.deb"
470-
gcloud compute ssh "$2" -- /bin/sh -c "set -eux; sudo dpkg -i --force-confdef /tmp/coder.deb; sudo systemctl daemon-reload; sudo service '$3' restart"
471-
set +x
472-
473-
echo "::endgroup::"
474-
done
475-
476-
- name: Upload build artifacts
477-
uses: actions/upload-artifact@v3
478-
with:
479-
name: coder
480-
path: |
481-
./build/*.zip
482-
./build/*.tar.gz
483-
./build/*.deb
484-
retention-days: 7
485-
486392
test-js:
487393
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
488394
needs: changes
@@ -722,9 +628,10 @@ jobs:
722628
723629
echo "Required checks have passed"
724630
725-
build-main-image:
726-
# This build and publihes ghcr.io/coder/coder-preview:main for each merge commit to main branch.
727-
# We are only building this for amd64 plateform. (>95% pulls are for amd64)
631+
build:
632+
# This builds and publishes ghcr.io/coder/coder-preview:main for each commit
633+
# to main branch. We are only building this for amd64 platform. (>95% pulls
634+
# are for amd64)
728635
needs: changes
729636
if: github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false'
730637
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
@@ -752,27 +659,34 @@ jobs:
752659
username: ${{ github.actor }}
753660
password: ${{ secrets.GITHUB_TOKEN }}
754661

755-
- name: Build and push Linux amd64 Docker image
756-
id: build_and_push
662+
- name: Build
757663
run: |
758664
set -euxo pipefail
759665
go mod download
760-
make gen/mark-fresh
761-
export DOCKER_IMAGE_NO_PREREQUISITES=true
666+
762667
version="$(./scripts/version.sh)"
668+
make gen/mark-fresh
669+
make -j \
670+
build/coder_linux_amd64 \
671+
build/coder_"$version"_windows_amd64.zip \
672+
build/coder_"$version"_linux_amd64.{tar.gz,deb}
673+
674+
- name: Build and Push Linux amd64 Docker Image
675+
run: |
676+
set -euxo pipefail
677+
tag="main-$(echo "$version" | sed 's/+/-/g')"
678+
763679
export CODER_IMAGE_BUILD_BASE_TAG="$(CODER_IMAGE_BASE=coder-base ./scripts/image_tag.sh --version "$version")"
764-
make -j build/coder_linux_amd64
765680
./scripts/build_docker.sh \
766681
--arch amd64 \
767-
--target ghcr.io/coder/coder-preview:main \
682+
--target "ghcr.io/coder/coder-preview:$tag" \
768683
--version $version \
769684
--push \
770685
build/coder_linux_amd64
771686
772-
# Tag image with new package tag and push
773-
tag=$(echo "$version" | sed 's/+/-/g')
774-
docker tag ghcr.io/coder/coder-preview:main ghcr.io/coder/coder-preview:main-$tag
775-
docker push ghcr.io/coder/coder-preview:main-$tag
687+
# Tag as main
688+
docker tag "ghcr.io/coder/coder-preview:$tag" ghcr.io/coder/coder-preview:main
689+
docker push ghcr.io/coder/coder-preview:main
776690
777691
- name: Prune old images
778692
uses: vlaurin/action-ghcr-prune@v0.5.0
@@ -784,3 +698,158 @@ jobs:
784698
keep-tags-regexes: ^pr
785699
prune-tags-regexes: ^main-
786700
prune-untagged: true
701+
702+
- name: Upload build artifacts
703+
uses: actions/upload-artifact@v3
704+
with:
705+
name: coder
706+
path: |
707+
./build/*.zip
708+
./build/*.tar.gz
709+
./build/*.deb
710+
retention-days: 7
711+
712+
deploy:
713+
name: "deploy"
714+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
715+
timeout-minutes: 30
716+
needs:
717+
- changes
718+
- build
719+
if: |
720+
github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
721+
&& needs.changes.outputs.docs-only == 'false'
722+
permissions:
723+
contents: read
724+
id-token: write
725+
steps:
726+
- name: Checkout
727+
uses: actions/checkout@v4
728+
with:
729+
fetch-depth: 0
730+
731+
- name: Authenticate to Google Cloud
732+
uses: google-github-actions/auth@v1
733+
with:
734+
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
735+
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com
736+
737+
- name: Set up Google Cloud SDK
738+
uses: google-github-actions/setup-gcloud@v1
739+
740+
- name: Set up Flux CLI
741+
uses: fluxcd/flux2/action@main
742+
743+
- name: Get Cluster Credentials
744+
uses: "google-github-actions/get-gke-credentials@v1"
745+
with:
746+
cluster_name: dogfood-v2
747+
location: us-central1-a
748+
project_id: coder-dogfood-v2
749+
750+
- name: Reconcile Flux
751+
run: |
752+
set -euxo pipefail
753+
flux --namespace flux-system reconcile source git flux-system
754+
flux --namespace flux-system reconcile source git coder-main
755+
flux --namespace flux-system reconcile kustomization flux-system
756+
flux --namespace flux-system reconcile kustomization coder
757+
flux --namespace flux-system reconcile source chart coder-coder
758+
flux --namespace coder reconcile helmrelease coder
759+
760+
# Just updating Flux is usually not enough. The Helm release may get
761+
# redeployed, but unless something causes the Deployment to update the
762+
# pods won't be recreated. It's important that the pods get recreated,
763+
# since we use `imagePullPolicy: Always` to ensure we're running the
764+
# latest image.
765+
- name: Rollout Deployment
766+
run: |
767+
set -euxo pipefail
768+
kubectl --namespace coder rollout restart deployment/coder
769+
kubectl --namespace coder rollout status deployment/coder
770+
771+
# TODO: when we remove this, instead of removing it we need to change it so it
772+
# still upgrades workspace proxies which are not deployed on K8s
773+
deploy-legacy:
774+
name: "deploy-legacy"
775+
runs-on: ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
776+
timeout-minutes: 30
777+
needs: changes
778+
if: |
779+
github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
780+
&& needs.changes.outputs.docs-only == 'false'
781+
permissions:
782+
contents: read
783+
id-token: write
784+
steps:
785+
- name: Checkout
786+
uses: actions/checkout@v4
787+
with:
788+
fetch-depth: 0
789+
790+
- name: Authenticate to Google Cloud
791+
uses: google-github-actions/auth@v1
792+
with:
793+
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
794+
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com
795+
796+
- name: Set up Google Cloud SDK
797+
uses: google-github-actions/setup-gcloud@v1
798+
799+
- name: Setup Node
800+
uses: ./.github/actions/setup-node
801+
802+
- name: Setup Go
803+
uses: ./.github/actions/setup-go
804+
805+
- name: Install goimports
806+
run: go install golang.org/x/tools/cmd/goimports@latest
807+
- name: Install nfpm
808+
run: go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
809+
810+
- name: Install zstd
811+
run: sudo apt-get install -y zstd
812+
813+
- name: Build Release
814+
run: |
815+
set -euo pipefail
816+
go mod download
817+
818+
version="$(./scripts/version.sh)"
819+
make gen/mark-fresh
820+
make -j \
821+
build/coder_"$version"_windows_amd64.zip \
822+
build/coder_"$version"_linux_amd64.{tar.gz,deb}
823+
824+
- name: Install Release
825+
run: |
826+
set -euo pipefail
827+
828+
regions=(
829+
# gcp-region-id instance-name systemd-service-name
830+
"us-central1-a coder coder"
831+
"australia-southeast1-b coder-sydney coder-workspace-proxy"
832+
"europe-west3-c coder-europe coder-workspace-proxy"
833+
"southamerica-east1-b coder-brazil coder-workspace-proxy"
834+
)
835+
836+
deb_pkg="./build/coder_$(./scripts/version.sh)_linux_amd64.deb"
837+
if [ ! -f "$deb_pkg" ]; then
838+
echo "deb package not found: $deb_pkg"
839+
ls -l ./build
840+
exit 1
841+
fi
842+
843+
gcloud config set project coder-dogfood
844+
for region in "${regions[@]}"; do
845+
echo "::group::$region"
846+
set -- $region
847+
848+
set -x
849+
gcloud config set compute/zone "$1"
850+
gcloud compute scp "$deb_pkg" "${2}:/tmp/coder.deb"
851+
gcloud compute ssh "$2" -- /bin/sh -c "set -eux; sudo dpkg -i --force-confdef /tmp/coder.deb; sudo systemctl daemon-reload; sudo service '$3' restart"
852+
set +x
853+
854+
echo "::endgroup::"
855+
done

.github/workflows/typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ darcula = "darcula"
1414
Hashi = "Hashi"
1515
trialer = "trialer"
1616
encrypter = "encrypter"
17+
hel = "hel" # as in helsinki
1718

1819
[files]
1920
extend-exclude = [

dogfood/main.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ terraform {
1111
}
1212

1313
locals {
14-
// These are Tailscale IP addresses. Ask Dean or Kyle for help.
14+
// These are cluster service addresses mapped to Tailscale nodes. Ask Dean or
15+
// Kyle for help.
1516
docker_host = {
16-
"" = "tcp://100.94.74.63:2375"
17-
"us-pittsburgh" = "tcp://100.94.74.63:2375"
18-
"eu-helsinki" = "tcp://100.117.102.81:2375"
19-
"ap-sydney" = "tcp://100.87.194.110:2375"
20-
"sa-saopaulo" = "tcp://100.99.64.123:2375"
21-
"eu-paris" = "tcp://100.74.161.61:2375"
17+
"" = "tcp://dogfood-ts-cdr-dev.tailscale.svc.cluster.local:2375"
18+
"us-pittsburgh" = "tcp://dogfood-ts-cdr-dev.tailscale.svc.cluster.local:2375"
19+
"eu-helsinki" = "tcp://reinhard-hel-cdr-dev.tailscale.svc.cluster.local:2375"
20+
"ap-sydney" = "tcp://hildegard-sydney-cdr-dev.tailscale.svc.cluster.local:2375"
21+
"sa-saopaulo" = "tcp://oberstein-sao-cdr-dev.tailscale.svc.cluster.local:2375"
2222
}
2323

2424
repo_dir = replace(data.coder_parameter.repo_dir.value, "/^~\\//", "/home/coder/")

0 commit comments

Comments
 (0)