Skip to content
Merged
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
14 changes: 14 additions & 0 deletions .github/workflows/commitmsg-conform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Commit Message Conformance

on:
pull_request: {}

permissions:
statuses: write
checks: write
contents: read
pull-requests: read

jobs:
commitmsg-conform:
uses: actionsforge/actions/.github/workflows/commitmsg-conform.yml@main
124 changes: 124 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
name: Build and Release Lambda

on:
pull_request:
branches: [ main ]
push:
branches: [ main ]

env:
FUNCTION_NAME: lambda-basic
RUNTIME: nodejs20.x
HANDLER: index.handler

permissions:
contents: write
packages: write

jobs:
validate:
name: Validate and Test
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'src/package-lock.json'

- name: Install dependencies
run: |
cd src
npm ci

- name: Run tests
run: |
cd src
npm test

- name: Build function
run: |
cd src
npm run build

- name: Package function
run: |
cd src
npm run package

- name: Verify package
run: |
if [ ! -f "src/function.zip" ]; then
echo "❌ Package file not created"
exit 1
fi
echo "✅ Package file created successfully"
ls -la src/function.zip

release:
name: Create Release
runs-on: ubuntu-latest
needs: validate
if: github.event_name == 'push' && github.ref == 'refs/heads/main'

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: 'src/package-lock.json'

- name: Install dependencies
run: |
cd src
npm ci

- name: Build function
run: |
cd src
npm run build

- name: Package function
run: |
cd src
npm run package

- name: Create Release
uses: softprops/action-gh-release@v1
with:
files: src/function.zip
tag_name: v${{ github.run_number }}
name: Release v${{ github.run_number }}
body: |
## Lambda Function Release

**Function:** ${{ env.FUNCTION_NAME }}
**Runtime:** ${{ env.RUNTIME }}
**Handler:** ${{ env.HANDLER }}

### Installation
1. Download the `function.zip` file
2. Upload to AWS Lambda console or use AWS CLI
3. Set handler to: `index.handler`
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Tag Latest
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -f latest
git push origin latest --force
14 changes: 14 additions & 0 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Markdown Lint

on:
pull_request: {}

permissions:
statuses: write
checks: write
contents: read
pull-requests: read

jobs:
markdown-lint:
uses: actionsforge/actions/.github/workflows/markdown-lint.yml@main
110 changes: 110 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Dependencies
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Coverage directory used by tools like istanbul
coverage/
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage
.grunt

# Bower dependency directory
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons
build/Release

# Dependency directories
jspm_packages/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test
.env.production

# parcel-bundler cache
.cache
.parcel-cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
public

# Storybook build outputs
.out
.storybook-out

# Temporary folders
tmp/
temp/

# Lambda deployment packages - NEVER commit these
*.zip
function.zip
src/function.zip
**/function.zip
src/lambda-basic-v*.zip
**/lambda-basic-v*.zip

# Build artifacts
dist/
build/

# AWS SAM
.aws-sam/

# IDE
.vscode/
.idea/
*.swp
*.swo

# OS
.DS_Store
Thumbs.db
76 changes: 74 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,74 @@
# lambda-basic
Basic Lambda function for testing or demo deployments
# Lambda Basic

A simple AWS Lambda function with automated CI/CD and releases.

## Structure

```plaintext
lambda-basic/
├── src/ # Lambda function code
├── .github/workflows/ # GitHub Actions
└── deploy.sh # Local deployment
```

## Quick Start

```bash
# Install dependencies
npm install

# Test locally
npm run test

# Package for deployment
npm run package
```

## Deployment

### GitHub Releases (Recommended)

- Push to `main` branch triggers automatic release
- Download `function.zip` from releases
- Upload to AWS Lambda

### Local Deployment

```bash
./deploy.sh
```

## CI/CD

- **PR**: Validation and testing
- **Main**: Creates release with `function.zip`
- **Tags**: `v{number}` + `latest`

## Configuration

- **Runtime**: Node.js 20.x
- **Handler**: `index.handler`
- **No environment variables needed**

## IAM Permissions

```json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
}
]
}
```

## License

MIT License
Loading