49 lines
1.1 KiB
YAML
49 lines
1.1 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
|
|
if: ${{ gitea.ref_name == 'main' || startsWith(gitea.ref_name, 'v') }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Build Docker image
|
|
run: docker build -t max-telegram-bridge-bot:latest .
|
|
|
|
- name: Deploy with Docker Compose
|
|
working-directory: C:\docker\DockerCompose_directory\max-telegram-bridge-bot-0.3.2
|
|
run: docker-compose up -d --build
|
|
|
|
- name: Health check
|
|
run: |
|
|
echo "Waiting for container to start..."
|
|
timeout /t 10
|
|
docker ps --filter "name=bridge" --format "table {{.Names}}\t{{.Status}}\t{{.Image}}"
|