Skip to content

move devcontainer to templates #7

move devcontainer to templates

move devcontainer to templates #7

Workflow file for this run

name: Test Template
on:
push:
branches:
- main
pull_request:
branches:
- main
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test-template:
name: Test Template (${{ matrix.protocol }}${{ matrix.auth != 'none' && format(' + {0}', matrix.auth) || '' }}${{ matrix.frontend != 'none' && format(' + {0}', matrix.frontend) || '' }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- protocol: rest
answers_file: sample/answers-rest.json
project_name: sample-app
auth: none
frontend: none
- protocol: rest
answers_file: sample/answers-rest-shadcn.json
project_name: sample-app
auth: none
frontend: shadcn-admin-kit
- protocol: rest
answers_file: sample/answers-rest-jwt.json
project_name: sample-app-jwt
auth: jwt
frontend: none
- protocol: grpc
answers_file: sample/answers-grpc.json
project_name: sample-grpc-app
auth: none
frontend: none
steps:
- name: Checkout repository
uses: actions/checkout@v5
with:
submodules: true
- name: Install Baker
run: curl --proto '=https' --tlsv1.2 -LsSf https://github.com/aliev/baker/releases/latest/download/baker-installer.sh | sh
- name: Generate project from template
run: |
mkdir -p generated
cat ${{ matrix.answers_file }} | baker . ./generated --answers - --force --non-interactive --skip-confirms all
- name: Set up Helm
uses: azure/setup-helm@v4
with:
version: v3.14.0
- name: Check if Helm chart exists
id: check-helm
run: |
if [ -d "generated/helm" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Lint Helm chart
if: steps.check-helm.outputs.exists == 'true'
working-directory: generated/helm
run: helm lint .
- name: Package Helm chart
if: steps.check-helm.outputs.exists == 'true'
working-directory: generated/helm
run: helm package .
- name: Template Helm chart (dry-run)
if: steps.check-helm.outputs.exists == 'true'
working-directory: generated/helm
run: helm template ${{ matrix.project_name }} . --debug
- name: Skip Helm build
if: steps.check-helm.outputs.exists == 'false'
run: echo "⚠️ Helm chart not found in generated project (helm feature not enabled)"
# Docker build steps
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Check if Dockerfile exists
id: check-dockerfile
run: |
if [ -f "generated/Dockerfile" ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
fi
- name: Login to dhi.io registry
if: steps.check-dockerfile.outputs.exists == 'true'
uses: docker/login-action@v3
with:
registry: dhi.io
username: ${{ secrets.DHI_USER }}
password: ${{ secrets.DHI_TOKEN }}
- name: Build Docker image
if: steps.check-dockerfile.outputs.exists == 'true'
uses: docker/build-push-action@v6
with:
context: generated/
push: false
tags: ${{ matrix.project_name }}:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Skip Docker build
if: steps.check-dockerfile.outputs.exists == 'false'
run: echo "⚠️ Dockerfile not found in generated project"