Skip to content
Merged

Dev #26

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ body:
attributes:
label: Problem or Need
description: Is this feature related to solving a problem? Please describe.
placeholder: Example: I'm always frustrated when...
placeholder: "Example: I'm always frustrated when..."
validations:
required: true

Expand Down
61 changes: 61 additions & 0 deletions .github/workflows/ci-backend.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: CI Backend

on:
push:
branches: [main, dev]
paths:
- "backend/**"
- ".github/workflows/ci-backend.yml"
pull_request:
branches: [main, dev]
paths:
- "backend/**"
- ".github/workflows/ci-backend.yml"

permissions:
contents: read

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
cache: "npm"
cache-dependency-path: backend/package-lock.json

- name: Install dependencies
working-directory: ./backend
run: npm ci

- name: Build project
working-directory: ./backend
run: npm run build

type-check:
name: Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5

- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: "22"
cache: "npm"
cache-dependency-path: backend/package-lock.json

- name: Install dependencies
working-directory: ./backend
run: npm ci

- name: Type check
working-directory: ./backend
run: npx tsc --noEmit
2 changes: 1 addition & 1 deletion .github/workflows/ci-infrastructure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
working-directory: ./infrastructure
run: npm run build

lint:
type-check:
name: Type Check
runs-on: ubuntu-latest
steps:
Expand Down
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
# Mostage Studio

![CI Frontend](https://github.com/mostage-app/studio/actions/workflows/ci-frontend.yml/badge.svg)
![CI Backend](https://github.com/mostage-app/studio/actions/workflows/ci-backend.yml/badge.svg)
![CI Infrastructure](https://github.com/mostage-app/studio/actions/workflows/ci-infrastructure.yml/badge.svg)

![Next.js](https://img.shields.io/badge/Next.js-15.5.5-black?logo=next.js)
![React](https://img.shields.io/badge/React-19.1.0-blue?logo=react)
![TypeScript](https://img.shields.io/badge/TypeScript-5-blue?logo=typescript)
![AWS CDK](https://img.shields.io/badge/AWS%20CDK-2.100.0-orange?logo=aws)
![React](https://img.shields.io/badge/React-19.1.0-61DAFB?logo=react&logoColor=white)
![TypeScript](https://img.shields.io/badge/TypeScript-5-3178C6?logo=typescript&logoColor=white)
![Tailwind CSS](https://img.shields.io/badge/Tailwind%20CSS-4-38B2AC?logo=tailwind-css&logoColor=white)
![Node.js](https://img.shields.io/badge/Node.js-20-339933?logo=node.js&logoColor=white)

![AWS CDK](https://img.shields.io/badge/AWS%20CDK-2.100.0-FF9900?logo=amazon-aws&logoColor=white)
![AWS Lambda](https://img.shields.io/badge/AWS%20Lambda-FF9900?logo=aws-lambda&logoColor=white)
![AWS DynamoDB](https://img.shields.io/badge/AWS%20DynamoDB-FF9900?logo=amazon-dynamodb&logoColor=white)
![AWS Cognito](https://img.shields.io/badge/AWS%20Cognito-FF9900?logo=amazon-aws&logoColor=white)
![AWS API Gateway](https://img.shields.io/badge/AWS%20API%20Gateway-FF9900?logo=amazon-api-gateway&logoColor=white)
![AWS S3](https://img.shields.io/badge/AWS%20S3-FF9900?logo=amazon-s3&logoColor=white)
![AWS Amplify](https://img.shields.io/badge/AWS%20Amplify-FF9900?logo=aws-amplify&logoColor=white)

Mostage Studio is a simple online tool for making presentations with Markdown and HTML. Some features include AI Creation, Live Polling System, and Audience Q&A.

Expand Down
23 changes: 22 additions & 1 deletion backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Backend Lambda functions for Mostage Studio.

## Structure

```
```text
backend/
src/
lambda/
Expand Down Expand Up @@ -93,3 +93,24 @@ Watch mode:
```bash
npm run watch
```

## CI/CD

The backend has automated CI checks via GitHub Actions. The CI workflow runs on:

- Push to `main` or `dev` branches when files in `backend/` change
- Pull requests to `main` or `dev` branches when files in `backend/` change

**CI Jobs**:

- **Build**: Compiles TypeScript to JavaScript
- **Type Check**: Validates TypeScript types

To run CI checks locally:

```bash
npm run build
npx tsc --noEmit
```

See [CI/CD Documentation](../docs/ci-cd.md) for more details.
101 changes: 33 additions & 68 deletions docs/ci-cd.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ This document describes the Continuous Integration and Continuous Deployment (CI

## Overview

The project uses GitHub Actions for automated testing, building, and deployment. There are three main workflows:
The project uses GitHub Actions for automated testing, building, and deployment. There are three main CI workflows:

1. **CI Frontend Workflow** - Runs on frontend changes
2. **CI Infrastructure Workflow** - Runs on infrastructure changes
3. **Deploy Frontend Workflow** - Deploys frontend to GitHub Pages
2. **CI Backend Workflow** - Runs on backend changes
3. **CI Infrastructure Workflow** - Runs on infrastructure changes

**Note**: Infrastructure deployment is performed **manually** using AWS CDK commands locally. See [Infrastructure Setup](infrastructure.md) for deployment instructions.
**Note**: Infrastructure deployment is performed **manually** using AWS CDK commands locally. Frontend deployment is handled by AWS Amplify (see `amplify.yml`). See [Infrastructure Setup](infrastructure.md) for deployment instructions.

## Workflows

Expand Down Expand Up @@ -47,96 +47,54 @@ The project uses GitHub Actions for automated testing, building, and deployment.

**Location**: `.github/workflows/ci-infrastructure.yml`

### 3. Deploy Frontend Workflow (`deploy-frontend.yml`)
### 3. CI Backend Workflow (`ci-backend.yml`)

**Purpose**: Deploys the frontend application to GitHub Pages
**Purpose**: Automated validation for backend Lambda functions

**Triggers**:

- Push to `main` branch **only when files in `frontend/` change**
- Manual trigger via `workflow_dispatch`
- Push to `main` or `dev` branches **only when files in `backend/` change**
- Pull requests to `main` or `dev` branches **only when files in `backend/` change**

**Process**:

1. Installs dependencies
2. Builds the Next.js application (lint and type-check are handled by CI workflow)
3. Uploads build artifacts
4. Deploys to GitHub Pages

**Note**: This workflow only builds and deploys. Lint and type-check are performed by the CI Frontend workflow to avoid duplicate work.

**Environment Variables**:

- `NEXT_PUBLIC_GA_MEASUREMENT_ID` (optional) - Google Analytics ID
- `NEXT_PUBLIC_COGNITO_USER_POOL_ID_PROD` (required) - Production Cognito User Pool ID
- `NEXT_PUBLIC_COGNITO_CLIENT_ID_PROD` (required) - Production Cognito Client ID
- `NEXT_PUBLIC_AWS_REGION` (required) - AWS Region (e.g., `eu-central-1`)
- `NEXT_PUBLIC_API_URL` (required) - API Gateway URL for backend services
**Jobs**:

**Note**: These environment variables must be set in GitHub Secrets (Settings → Secrets and variables → Actions) because Next.js requires them at build time for static export.
- **Build**: Compiles TypeScript to JavaScript
- **Type Check**: Validates TypeScript types

**Location**: `.github/workflows/deploy-frontend.yml`
**Location**: `.github/workflows/ci-backend.yml`

## GitHub Setup

### Required Secrets

Go to **Settings → Secrets and variables → Actions** and add:

#### For Frontend Deploy

- `NEXT_PUBLIC_GA_MEASUREMENT_ID` (optional) - Google Analytics Measurement ID
- `NEXT_PUBLIC_COGNITO_USER_POOL_ID_PROD` (required) - Production Cognito User Pool ID
- `NEXT_PUBLIC_COGNITO_CLIENT_ID_PROD` (required) - Production Cognito Client ID
- `NEXT_PUBLIC_AWS_REGION` (required) - AWS Region (e.g., `eu-central-1`)
- `NEXT_PUBLIC_API_URL` (required) - API Gateway URL for backend services

### Required Environments

Go to **Settings → Environments** and create:

#### `github-pages`

- Usually created automatically
- Used for frontend deployment

### GitHub Pages Configuration

Go to **Settings → Pages**:

- **Source**: Select "GitHub Actions"
- **Branch**: `main` (or your default branch)
Currently, no GitHub Secrets are required for CI workflows. Environment variables for frontend builds are handled by AWS Amplify (see `amplify.yml`).

## Workflow Files

```text
.github/workflows/
├── ci-frontend.yml # Frontend CI checks (lint, type-check, build)
├── ci-infrastructure.yml # Infrastructure CI checks (validate, format)
└── deploy-frontend.yml # Frontend deployment to GitHub Pages
├── ci-backend.yml # Backend CI checks (build, type-check)
└── ci-infrastructure.yml # Infrastructure CI checks (build, type-check)
```

**Note**: Frontend deployment is handled by AWS Amplify (see `amplify.yml` in the root directory).

## Usage

### Running CI Checks

CI checks run automatically on:

- **Frontend CI**: When files in `frontend/` change
- **Backend CI**: When files in `backend/` change
- **Infrastructure CI**: When files in `infrastructure/` change

You can also manually trigger from **Actions → CI Frontend** or **Actions → CI Infrastructure**
You can also manually trigger from **Actions → CI Frontend**, **Actions → CI Backend**, or **Actions → CI Infrastructure**

### Deploying Frontend

Frontend deploys automatically when you push to `main` branch.

To deploy manually:

1. Go to **Actions → Deploy Frontend**
2. Click **Run workflow**
3. Select branch (usually `main`)
4. Click **Run workflow**
Frontend deployment is handled by AWS Amplify. See `amplify.yml` in the root directory for configuration.

### Deploying Infrastructure

Expand Down Expand Up @@ -202,24 +160,31 @@ See [Infrastructure Setup](infrastructure.md) for detailed instructions.
- Check type check output in Actions logs
- Type check locally: `cd infrastructure && npx tsc --noEmit`

### Deploy Frontend Fails
### CI Backend Workflow Fails

**Build errors**:

- Check if environment variables are set correctly
- Verify `NEXT_PUBLIC_GA_MEASUREMENT_ID` is set (if using analytics)
- Check build output in Actions logs
- Build locally: `cd backend && npm run build`

**Deployment errors**:
**TypeScript type errors**:

- Check GitHub Pages settings
- Verify Pages source is set to "GitHub Actions"
- Check type check output in Actions logs
- Type check locally: `cd backend && npx tsc --noEmit`

## Best Practices

1. **Always run CI locally** before pushing:

```bash
# Frontend
cd frontend && npm run lint && npx tsc --noEmit && npm run build

# Backend
cd backend && npm run build && npx tsc --noEmit

# Infrastructure
cd infrastructure && npm run build && npx tsc --noEmit
```

2. **Review CI results** before merging PRs
Expand Down
Loading
Loading