feat: setup Gitea Actions CI/CD and Docker configuration
CI / CD / Lint & Build (CI) (push) Successful in 11m42s
CI / CD / Build & Push Docker Image (CD) (push) Failing after 3m49s

This commit is contained in:
2026-11-21 01:53:02 +07:00
parent 8a2ad04492
commit 4cb903f2f7
6 changed files with 204 additions and 0 deletions
+8
View File
@@ -0,0 +1,8 @@
node_modules
dist
auth
.git
.gitignore
.gitea
.github
*.md
+74
View File
@@ -0,0 +1,74 @@
name: CI / CD
on:
push:
branches:
- main
tags:
- 'v*'
pull_request:
branches:
- main
permissions:
contents: read
packages: write
jobs:
ci:
name: Lint & Build (CI)
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Type-check and compile
run: npm run build
cd:
name: Build & Push Docker Image (CD)
needs: [ci]
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to Gitea Container Registry
uses: docker/login-action@v3
with:
registry: git.hrkm.my.id
username: ${{ github.actor }}
password: ${{ secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: |
git.hrkm.my.id/hira/wauto
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=tag
type=sha,format=short
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
+36
View File
@@ -0,0 +1,36 @@
# Stage 1: Build TypeScript source code
FROM node:22-bookworm-slim AS builder
WORKDIR /app
# Install dependencies
COPY package*.json ./
RUN npm ci
# Copy TypeScript configuration and source
COPY tsconfig.json ./
COPY index.ts ./
# Compile to JavaScript (dist/)
RUN npm run build
# Stage 2: Production runtime image
FROM node:22-bookworm-slim AS runner
WORKDIR /app
ENV NODE_ENV=production
# Install only production dependencies
COPY package*.json ./
RUN npm ci --omit=dev && npm cache clean --force
# Copy compiled code from builder
COPY --from=builder /app/dist ./dist
# Create auth folder for persistent WhatsApp credentials
RUN mkdir -p /app/auth
VOLUME ["/app/auth"]
CMD ["npm", "start"]
+77
View File
@@ -0,0 +1,77 @@
# wauto 🤖
A WhatsApp bot built with TypeScript, [Baileys](https://github.com/WhiskeySockets/Baileys), and [Sharp](https://sharp.pixelplumbing.com/).
## Features
- `!ping` - Responds with pong
- `!time` - Current time in WIB (Asia/Jakarta)
- `!echo <text>` - Echoes your message
- `!sticker` / `!stiker` / `!s` - Converts sent or quoted image/video/sticker into a WhatsApp sticker
- `!help` - Displays command list
---
## Local Development
1. Install dependencies:
```bash
npm install
```
2. Run in development mode (with auto-reload):
```bash
npm run dev
```
3. Build and run production build:
```bash
npm run build
npm start
```
---
## CI / CD with Gitea Actions
The repository includes automated CI/CD configured in [`.gitea/workflows/ci-cd.yaml`](.gitea/workflows/ci-cd.yaml):
1. **CI (Continuous Integration)**:
- Triggers on every `push` and `pull_request` targeting `main`.
- Runs `npm ci` and `npm run build` (TypeScript compilation & type checking).
2. **CD (Continuous Delivery)**:
- Triggers on `push` to `main` and version tags (`v*`).
- Builds a production-ready, multi-stage Docker container.
- Pushes the image to the Gitea Container Registry:
```
git.hrkm.my.id/hira/wauto:latest
```
### Authentication for Gitea Actions Runner
The workflow uses `${{ secrets.GITEA_TOKEN || secrets.GITHUB_TOKEN }}`.
- If your Gitea instance has Actions package permissions enabled, `${{ secrets.GITHUB_TOKEN }}` works automatically.
- Alternatively, you can add a repository secret named `GITEA_TOKEN` with a Personal Access Token (`read:package`, `write:package`).
---
## Deployment with Docker Compose
Deploy the bot on your server using the included [`docker-compose.yml`](docker-compose.yml):
1. Log in to Gitea Container Registry on your server:
```bash
docker login git.hrkm.my.id
```
2. Pull and start the container:
```bash
docker compose pull
docker compose up -d
```
3. Scan the WhatsApp QR code to link your account:
```bash
docker compose logs -f
```
> **Important**: The `./auth` directory is mounted into `/app/auth` inside the container so your session login credentials persist across container restarts and updates.
+8
View File
@@ -0,0 +1,8 @@
services:
wauto:
image: git.hrkm.my.id/hira/wauto:latest
container_name: wauto
restart: unless-stopped
volumes:
# Persistent storage for WhatsApp session credentials
- ./auth:/app/auth
+1
View File
@@ -5,6 +5,7 @@
"main": "dist/index.js",
"scripts": {
"build": "tsc",
"typecheck": "tsc --noEmit",
"start": "node dist/index.js",
"dev": "tsx index.ts"
},