This commit is contained in:
anthorob committed 2026-03-18 09:27:11 -04:00
1 parent ec8c148d1e
commit ad0aac7b35
1 file changed
+26 -50
+26 -50
View File
@@ -12,43 +12,25 @@ on:
workflow_dispatch:
jobs:
checkout:
name: Checkout repository
validate:
name: Validate templates
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Upload repo files as artifact
uses: actions/upload-artifact@v3
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
name: source
path: |
base
templates
terraform_version: "1.7.0"
validate:
name: Validate templates
needs: checkout
runs-on: ubuntu-latest
steps:
- name: Download source artifact
uses: actions/download-artifact@v3
with:
name: source
- name: Terraform validate for each template (docker)
- name: Terraform validate for each template
run: |
docker run --rm \
-v "$PWD":/workspace \
-w /workspace \
gitea.bobert.me/anthorob/coder-base:terraform sh -c '
for dir in templates/*; do
[ -d "$dir" ] || continue
echo "==> validating $dir"
terraform -chdir="$dir" init -backend=false
terraform -chdir="$dir" validate
done
'
for dir in templates/*; do
[ -d "$dir" ] || continue
echo "==> validating $dir"
terraform -chdir="$dir" init -backend=false
terraform -chdir="$dir" validate
done
deploy:
name: Deploy templates
@@ -58,27 +40,21 @@ jobs:
COMMIT_SHORT_SHA: ${{ github.sha }}
REPO: ${{ github.repository }}
steps:
- name: Download source artifact
uses: actions/download-artifact@v3
with:
name: source
- uses: actions/checkout@v4
- name: Deploy each template (docker)
- name: Install Coder CLI
run: |
curl -fsSL https://coder.com/install.sh | sh
- name: Deploy each template
run: |
short_sha=${COMMIT_SHORT_SHA:0:7}
docker run --rm \
-v "$PWD":/workspace \
-w /workspace \
-e COMMIT_SHORT_SHA \
-e REPO \
gitea.bobert.me/anthorob/coder-base:cli sh -c '
for dir in templates/*; do
[ -d "$dir" ] || continue
name=$(basename "$dir")
display_name=$(echo "$name" | sed "s/.*/\u&/" | sed "s/-/ /g")
for dir in templates/*; do
[ -d "$dir" ] || continue
name=$(basename "$dir")
display_name=$(echo "$name" | sed "s/.*/\u&/" | sed "s/-/ /g")
echo "==> deploying $name"
coder templates push -d "$dir" --name "$short_sha" --message "Auto-deployed from $REPO on commit $short_sha" --yes "$name"
coder templates edit "$name" --display-name "$display_name Dev Environment" --description "Development environment for $name" --icon "/icon/$name.svg" --yes
done
'
echo "==> deploying $name"
coder templates push -d "$dir" --name "$short_sha" --message "Auto-deployed from $REPO on commit $short_sha" --yes "$name"
coder templates edit "$name" --display-name "$display_name Dev Environment" --description "Development environment for $name" --icon "/icon/$name.svg" --yes
done