53 lines
1.2 KiB
YAML
53 lines
1.2 KiB
YAML
name: Build and Deploy
|
|
run-name: Deploy ${{ gitea.ref_name }}
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags: ['v*']
|
|
|
|
jobs:
|
|
ci:
|
|
name: Check and Build
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.24'
|
|
|
|
- name: Vet
|
|
run: go vet ./...
|
|
|
|
- name: Test
|
|
run: go test ./...
|
|
|
|
- name: Build binary
|
|
run: CGO_ENABLED=1 go build -o max-telegram-bridge-bot .
|
|
|
|
deploy:
|
|
name: Deploy to Production
|
|
needs: ci
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build Docker image
|
|
run: docker build -t max-telegram-bridge-bot:latest .
|
|
|
|
- name: Create .env file from secrets
|
|
run: |
|
|
echo "TG_TOKEN=${{ secrets.TG_TOKEN }}" > .env
|
|
echo "MAX_TOKEN=${{ secrets.MAX_TOKEN }}" >> .env
|
|
echo "TG_API_URL=${{ secrets.TG_API_URL }}" >> .env
|
|
|
|
- name: Deploy with Docker Compose
|
|
run: docker-compose up -d
|
|
|
|
- name: Health check
|
|
run: |
|
|
echo "Waiting for container to start..."
|
|
sleep 10
|
|
docker ps --filter "name=bridge" --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
|