31
31
runs-on : ubuntu-latest
32
32
outputs :
33
33
docs-only : ${{ steps.filter.outputs.docs_count == steps.filter.outputs.all_count }}
34
+ docs : ${{ steps.filter.outputs.docs }}
34
35
go : ${{ steps.filter.outputs.go }}
35
36
ts : ${{ steps.filter.outputs.ts }}
36
37
k8s : ${{ steps.filter.outputs.k8s }}
@@ -388,120 +389,6 @@ jobs:
388
389
with :
389
390
api-key : ${{ secrets.DATADOG_API_KEY }}
390
391
391
- deploy :
392
- name : " deploy"
393
- runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
394
- timeout-minutes : 30
395
- needs : changes
396
- if : |
397
- github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
398
- && needs.changes.outputs.docs-only == 'false'
399
- permissions :
400
- contents : read
401
- id-token : write
402
- steps :
403
- - name : Checkout
404
- uses : actions/checkout@v4
405
- with :
406
- fetch-depth : 0
407
-
408
- - name : Authenticate to Google Cloud
409
- uses : google-github-actions/auth@v1
410
- with :
411
- workload_identity_provider : projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
412
- service_account : coder-ci@coder-dogfood.iam.gserviceaccount.com
413
-
414
- - name : Set up Google Cloud SDK
415
- uses : google-github-actions/setup-gcloud@v1
416
-
417
- - name : Setup Node
418
- uses : ./.github/actions/setup-node
419
-
420
- - name : Setup Go
421
- uses : ./.github/actions/setup-go
422
-
423
- - name : Install goimports
424
- run : go install golang.org/x/tools/cmd/goimports@latest
425
- - name : Install nfpm
426
- run : go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
427
-
428
- - name : Install zstd
429
- run : sudo apt-get install -y zstd
430
-
431
- - name : Build Release
432
- run : |
433
- set -euo pipefail
434
- go mod download
435
-
436
- version="$(./scripts/version.sh)"
437
- make gen/mark-fresh
438
- make -j \
439
- build/coder_"$version"_windows_amd64.zip \
440
- build/coder_"$version"_linux_amd64.{tar.gz,deb}
441
-
442
- - name : Install Release
443
- run : |
444
- set -euo pipefail
445
-
446
- regions=(
447
- # gcp-region-id instance-name systemd-service-name
448
- "us-central1-a coder coder"
449
- "australia-southeast1-b coder-sydney coder-workspace-proxy"
450
- "europe-west3-c coder-europe coder-workspace-proxy"
451
- "southamerica-east1-b coder-brazil coder-workspace-proxy"
452
- )
453
-
454
- deb_pkg="./build/coder_$(./scripts/version.sh)_linux_amd64.deb"
455
- if [ ! -f "$deb_pkg" ]; then
456
- echo "deb package not found: $deb_pkg"
457
- ls -l ./build
458
- exit 1
459
- fi
460
-
461
- gcloud config set project coder-dogfood
462
- for region in "${regions[@]}"; do
463
- echo "::group::$region"
464
- set -- $region
465
-
466
- set -x
467
- gcloud config set compute/zone "$1"
468
- gcloud compute scp "$deb_pkg" "${2}:/tmp/coder.deb"
469
- 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"
470
- set +x
471
-
472
- echo "::endgroup::"
473
- done
474
-
475
- - name : Upload build artifacts
476
- uses : actions/upload-artifact@v3
477
- with :
478
- name : coder
479
- path : |
480
- ./build/*.zip
481
- ./build/*.tar.gz
482
- ./build/*.deb
483
- retention-days : 7
484
-
485
- deploy-wsproxies :
486
- runs-on : ubuntu-latest
487
- needs : build-main-image
488
- steps :
489
- - name : Checkout
490
- uses : actions/checkout@v4
491
- with :
492
- fetch-depth : 0
493
-
494
- - name : Setup flyctl
495
- uses : superfly/flyctl-actions/setup-flyctl@master
496
-
497
- - name : Deploy workspace proxies
498
- run : |
499
- flyctl deploy --image ghcr.io/coder/coder-preview:main --app paris-coder -y
500
- flyctl deploy --image ghcr.io/coder/coder-preview:main --app sydney-coder -y
501
- flyctl deploy --image ghcr.io/coder/coder-preview:main --app sao-paulo-coder -y
502
- env :
503
- FLY_API_TOKEN : ${{ secrets.FLY_API_TOKEN }}
504
-
505
392
test-js :
506
393
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
507
394
needs : changes
@@ -667,7 +554,8 @@ jobs:
667
554
name : offlinedocs
668
555
needs : changes
669
556
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
670
- if : needs.changes.outputs.offlinedocs == 'true' || needs.changes.outputs.ci == 'true'
557
+ if : needs.changes.outputs.offlinedocs == 'true' || needs.changes.outputs.ci == 'true' || needs.changes.outputs.docs == 'true'
558
+
671
559
steps :
672
560
- name : Checkout
673
561
uses : actions/checkout@v4
@@ -740,9 +628,10 @@ jobs:
740
628
741
629
echo "Required checks have passed"
742
630
743
- build-main-image :
744
- # This build and publihes ghcr.io/coder/coder-preview:main for each merge commit to main branch.
745
- # 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)
746
635
needs : changes
747
636
if : github.ref == 'refs/heads/main' && needs.changes.outputs.docs-only == 'false'
748
637
runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-8vcpu-ubuntu-2204' || 'ubuntu-latest' }}
@@ -770,27 +659,34 @@ jobs:
770
659
username : ${{ github.actor }}
771
660
password : ${{ secrets.GITHUB_TOKEN }}
772
661
773
- - name : Build and push Linux amd64 Docker image
774
- id : build_and_push
662
+ - name : Build
775
663
run : |
776
664
set -euxo pipefail
777
665
go mod download
778
- make gen/mark-fresh
779
- export DOCKER_IMAGE_NO_PREREQUISITES=true
666
+
780
667
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
+
781
679
export CODER_IMAGE_BUILD_BASE_TAG="$(CODER_IMAGE_BASE=coder-base ./scripts/image_tag.sh --version "$version")"
782
- make -j build/coder_linux_amd64
783
680
./scripts/build_docker.sh \
784
681
--arch amd64 \
785
- --target ghcr.io/coder/coder-preview:main \
682
+ --target " ghcr.io/coder/coder-preview:$tag" \
786
683
--version $version \
787
684
--push \
788
685
build/coder_linux_amd64
789
686
790
- # Tag image with new package tag and push
791
- tag=$(echo "$version" | sed 's/+/-/g')
792
- docker tag ghcr.io/coder/coder-preview:main ghcr.io/coder/coder-preview:main-$tag
793
- 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
794
690
795
691
- name : Prune old images
796
692
uses : vlaurin/action-ghcr-prune@v0.5.0
@@ -802,3 +698,178 @@ jobs:
802
698
keep-tags-regexes : ^pr
803
699
prune-tags-regexes : ^main-
804
700
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
+ deploy-wsproxies :
772
+ runs-on : ubuntu-latest
773
+ needs : build-main-image
774
+ steps :
775
+ - name : Checkout
776
+ uses : actions/checkout@v4
777
+ with :
778
+ fetch-depth : 0
779
+
780
+ - name : Setup flyctl
781
+ uses : superfly/flyctl-actions/setup-flyctl@master
782
+
783
+ - name : Deploy workspace proxies
784
+ run : |
785
+ flyctl deploy --image ghcr.io/coder/coder-preview:main --app paris-coder -y
786
+ flyctl deploy --image ghcr.io/coder/coder-preview:main --app sydney-coder -y
787
+ flyctl deploy --image ghcr.io/coder/coder-preview:main --app sao-paulo-coder -y
788
+ env :
789
+ FLY_API_TOKEN : ${{ secrets.FLY_API_TOKEN }}
790
+
791
+ # TODO: when we remove this, instead of removing it we need to change it so it
792
+ # still upgrades workspace proxies which are not deployed on K8s
793
+ deploy-legacy :
794
+ name : " deploy-legacy"
795
+ runs-on : ${{ github.repository_owner == 'coder' && 'buildjet-16vcpu-ubuntu-2204' || 'ubuntu-latest' }}
796
+ timeout-minutes : 30
797
+ needs : changes
798
+ if : |
799
+ github.ref == 'refs/heads/main' && !github.event.pull_request.head.repo.fork
800
+ && needs.changes.outputs.docs-only == 'false'
801
+ permissions :
802
+ contents : read
803
+ id-token : write
804
+ steps :
805
+ - name : Checkout
806
+ uses : actions/checkout@v4
807
+ with :
808
+ fetch-depth : 0
809
+
810
+ - name : Authenticate to Google Cloud
811
+ uses : google-github-actions/auth@v1
812
+ with :
813
+ workload_identity_provider : projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
814
+ service_account : coder-ci@coder-dogfood.iam.gserviceaccount.com
815
+
816
+ - name : Set up Google Cloud SDK
817
+ uses : google-github-actions/setup-gcloud@v1
818
+
819
+ - name : Setup Node
820
+ uses : ./.github/actions/setup-node
821
+
822
+ - name : Setup Go
823
+ uses : ./.github/actions/setup-go
824
+
825
+ - name : Install goimports
826
+ run : go install golang.org/x/tools/cmd/goimports@latest
827
+ - name : Install nfpm
828
+ run : go install github.com/goreleaser/nfpm/v2/cmd/nfpm@v2.16.0
829
+
830
+ - name : Install zstd
831
+ run : sudo apt-get install -y zstd
832
+
833
+ - name : Build Release
834
+ run : |
835
+ set -euo pipefail
836
+ go mod download
837
+
838
+ version="$(./scripts/version.sh)"
839
+ make gen/mark-fresh
840
+ make -j \
841
+ build/coder_"$version"_windows_amd64.zip \
842
+ build/coder_"$version"_linux_amd64.{tar.gz,deb}
843
+
844
+ - name : Install Release
845
+ run : |
846
+ set -euo pipefail
847
+
848
+ regions=(
849
+ # gcp-region-id instance-name systemd-service-name
850
+ "us-central1-a coder coder"
851
+ "australia-southeast1-b coder-sydney coder-workspace-proxy"
852
+ "europe-west3-c coder-europe coder-workspace-proxy"
853
+ "southamerica-east1-b coder-brazil coder-workspace-proxy"
854
+ )
855
+
856
+ deb_pkg="./build/coder_$(./scripts/version.sh)_linux_amd64.deb"
857
+ if [ ! -f "$deb_pkg" ]; then
858
+ echo "deb package not found: $deb_pkg"
859
+ ls -l ./build
860
+ exit 1
861
+ fi
862
+
863
+ gcloud config set project coder-dogfood
864
+ for region in "${regions[@]}"; do
865
+ echo "::group::$region"
866
+ set -- $region
867
+
868
+ set -x
869
+ gcloud config set compute/zone "$1"
870
+ gcloud compute scp "$deb_pkg" "${2}:/tmp/coder.deb"
871
+ 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"
872
+ set +x
873
+
874
+ echo "::endgroup::"
875
+ done
0 commit comments