Skip to content

Commit a2733a1

Browse files
committed
chore(dogfood): move coder-envbuilder template under VCS control
1 parent 3a6b7cd commit a2733a1

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-0
lines changed

.github/workflows/dogfood.yaml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,3 +145,58 @@ jobs:
145145
TF_VAR_CODER_TEMPLATE_DIR: ./contents
146146
TF_VAR_CODER_TEMPLATE_MESSAGE: ${{ steps.message.outputs.pr_title }}
147147
TF_LOG: info
148+
149+
deploy_template_envbuilder:
150+
needs: build_image
151+
runs-on: ubuntu-latest
152+
steps:
153+
- name: Harden Runner
154+
uses: step-security/harden-runner@4d991eb9b905ef189e4c376166672c3f2f230481 # v2.11.0
155+
with:
156+
egress-policy: audit
157+
158+
- name: Checkout
159+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
160+
161+
- name: Setup Terraform
162+
uses: ./.github/actions/setup-tf
163+
164+
- name: Authenticate to Google Cloud
165+
uses: google-github-actions/auth@71f986410dfbc7added4569d411d040a91dc6935 # v2.1.8
166+
with:
167+
workload_identity_provider: projects/573722524737/locations/global/workloadIdentityPools/github/providers/github
168+
service_account: coder-ci@coder-dogfood.iam.gserviceaccount.com
169+
170+
- name: Terraform init and validate
171+
run: |
172+
cd dogfood/coder-envbuilder
173+
terraform init -upgrade
174+
terraform validate
175+
cd contents
176+
terraform init -upgrade
177+
terraform validate
178+
179+
- name: Get short commit SHA
180+
if: github.ref == 'refs/heads/main'
181+
id: vars
182+
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
183+
184+
- name: Get latest commit title
185+
if: github.ref == 'refs/heads/main'
186+
id: message
187+
run: echo "pr_title=$(git log --format=%s -n 1 ${{ github.sha }})" >> $GITHUB_OUTPUT
188+
189+
- name: "Push template"
190+
if: github.ref == 'refs/heads/main'
191+
run: |
192+
cd dogfood/coder-envbuilder
193+
terraform apply -auto-approve
194+
env:
195+
# Consumed by coderd provider
196+
CODER_URL: https://dev.coder.com
197+
CODER_SESSION_TOKEN: ${{ secrets.CODER_SESSION_TOKEN }}
198+
# Template source & details
199+
TF_VAR_CODER_TEMPLATE_VERSION: ${{ steps.vars.outputs.sha_short }}
200+
TF_VAR_CODER_TEMPLATE_DIR: ./contents
201+
TF_VAR_CODER_TEMPLATE_MESSAGE: ${{ steps.message.outputs.pr_title }}
202+
TF_LOG: info

dogfood/coder-envbuilder/main.tf

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
terraform {
2+
required_providers {
3+
coderd = {
4+
source = "coder/coderd"
5+
}
6+
}
7+
backend "gcs" {
8+
bucket = "coder-dogfood-tf-state"
9+
prefix = "/templates/coder-envbuilder"
10+
}
11+
}
12+
13+
data "coderd_organization" "default" {
14+
is_default = true
15+
}
16+
17+
data "coderd_user" "machine" {
18+
username = "machine"
19+
}
20+
21+
variable "CODER_TEMPLATE_VERSION" {
22+
type = string
23+
}
24+
25+
variable "CODER_TEMPLATE_DIR" {
26+
type = string
27+
}
28+
29+
variable "CODER_TEMPLATE_MESSAGE" {
30+
type = string
31+
}
32+
33+
resource "coderd_template" "dogfood" {
34+
name = "coder-envbuilder"
35+
display_name = "Write Coder on Coder using Envbuilder"
36+
description = "Write Coder on Coder using a workspace built by Envbuilder."
37+
icon = "/emojis/1f3d7.png" # 🏗️
38+
organization_id = "703f72a1-76f6-4f89-9de6-8a3989693fe5"
39+
versions = [
40+
{
41+
name = var.CODER_TEMPLATE_VERSION
42+
message = var.CODER_TEMPLATE_MESSAGE
43+
directory = var.CODER_TEMPLATE_DIR
44+
active = true
45+
tf_vars = [{
46+
# clusters/dogfood-v2/coder/provisioner/configs/values.yaml#L191-L194
47+
"envbuilder_cache_dockerconfigjson_path" = "/home/coder/envbuilder-cache-dockerconfig.json"
48+
}]
49+
}
50+
]
51+
acl = {
52+
groups = [{
53+
id = data.coderd_organization.default.id
54+
role = "use"
55+
}]
56+
users = [{
57+
id = data.coderd_user.machine.id
58+
role = "admin"
59+
}]
60+
}
61+
activity_bump_ms = 10800000
62+
allow_user_auto_start = true
63+
allow_user_auto_stop = true
64+
allow_user_cancel_workspace_jobs = false
65+
auto_start_permitted_days_of_week = ["friday", "monday", "saturday", "sunday", "thursday", "tuesday", "wednesday"]
66+
auto_stop_requirement = {
67+
days_of_week = ["sunday"]
68+
weeks = 1
69+
}
70+
default_ttl_ms = 28800000
71+
deprecation_message = null
72+
failure_ttl_ms = 604800000
73+
require_active_version = true
74+
time_til_dormant_autodelete_ms = 7776000000
75+
time_til_dormant_ms = 8640000000
76+
}

0 commit comments

Comments
 (0)