2 Commits

Author SHA1 Message Date
bf25c33b3f Исправлен workflow - 21 для сборки и релиза
All checks were successful
Release Build / create-docker-image (push) Successful in 4m28s
Release Build / create-release (push) Successful in 6m3s
2025-07-27 15:31:50 +06:00
c1e0f6e04f Исправлен workflow - 20 для сборки и релиза
Some checks failed
Release Build / release (push) Successful in 1m39s
Release Build / create-docker-image (push) Failing after 49s
Release Build / create-release (push) Has been skipped
2025-07-27 15:08:50 +06:00
3 changed files with 159 additions and 6 deletions

View File

@@ -8,10 +8,13 @@ jobs:
create-docker-image: create-docker-image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: golang:1.21 image: docker:28.3.2-dind
steps: steps:
- name: Checkout repository - name: Checkout repository
run: | run: |
# Install git
apk add --no-cache git
echo "=== GitHub Variables ===" echo "=== GitHub Variables ==="
echo "github.ref = ${{ github.ref }}" echo "github.ref = ${{ github.ref }}"
echo "github.ref_name = ${{ github.ref_name }}" echo "github.ref_name = ${{ github.ref_name }}"
@@ -24,12 +27,11 @@ jobs:
- name: Setup Docker Buildx - name: Setup Docker Buildx
run: | run: |
# Install Docker CLI # Docker is already installed in docker:dind image
apt-get update && apt-get install -y docker.io
docker --version docker --version
# Setup Docker Buildx for multi-platform builds # Setup Docker Buildx for multi-platform builds
docker buildx create --name multiplatform --use docker buildx create --use
docker buildx inspect --bootstrap docker buildx inspect --bootstrap
- name: Login to Docker Hub - name: Login to Docker Hub

155
README.md
View File

@@ -1,3 +1,154 @@
# hello_gitea # Hello Gitea API
test repo to try with actions - v1.0.11 Простой REST API сервер, построенный на Go с использованием Gin framework.
## 🚀 Возможности
- ✅ REST API с JSON ответами
- ✅ Health check endpoint
- ✅ CORS поддержка
- ✅ Мультиплатформенная сборка
- ✅ Docker образы для Linux AMD64/ARM64
- ✅ Автоматические релизы через Gitea Actions
## 📦 Установка
### Из бинарного файла
1. Скачайте бинарный файл для вашей платформы из [релизов](https://direct-dev.ru/gitea/GiteaAdmin/hello_gitea/releases)
2. Распакуйте архив
3. Запустите: `./hello-api-<platform>`
### Из Docker образа
```bash
docker pull <username>/hello-api:latest
docker run -p 8080:8080 <username>/hello-api:latest
```
### Из исходного кода
```bash
git clone https://direct-dev.ru/gitea/GiteaAdmin/hello_gitea.git
cd hello_gitea
go mod download
go run main.go
```
## 🔧 Конфигурация
Сервер запускается на порту 8080 по умолчанию. Можно изменить через переменную окружения:
```bash
export PORT=3000
./hello-api
```
## 📡 API Endpoints
### GET /
Основной endpoint
**Ответ:**
```json
{
"message": "Hello, World!",
"version": "1.0.0"
}
```
### GET /health
Health check endpoint
**Ответ:**
```json
{
"status": "ok",
"version": "1.0.0"
}
```
### GET /api/v1/info
Информация о сервисе
**Ответ:**
```json
{
"service": "hello-api",
"status": "running",
"version": "1.0.0"
}
```
### POST /api/v1/echo
Echo endpoint - возвращает отправленное сообщение
**Запрос:**
```json
{
"message": "Hello from client!"
}
```
**Ответ:**
```json
{
"echo": "Hello from client!",
"version": "1.0.0"
}
```
## 🛠 Разработка
### Зависимости
- Go 1.21+
- Gin framework
### Сборка
```bash
# Для текущей платформы
go build -o hello-api main.go
# Для Linux AMD64
GOOS=linux GOARCH=amd64 go build -o hello-api-linux-amd64 main.go
# Для Linux ARM64
GOOS=linux GOARCH=arm64 go build -o hello-api-linux-arm64 main.go
# Для Windows
GOOS=windows GOARCH=amd64 go build -o hello-api-windows-amd64.exe main.go
# Для macOS
GOOS=darwin GOARCH=amd64 go build -o hello-api-darwin-amd64 main.go
GOOS=darwin GOARCH=arm64 go build -o hello-api-darwin-arm64 main.go
```
### Тестирование
```bash
# Запуск сервера
go run main.go
# Тестирование API
curl http://localhost:8080/
curl http://localhost:8080/health
curl http://localhost:8080/api/v1/info
curl -X POST http://localhost:8080/api/v1/echo \
-H "Content-Type: application/json" \
-d '{"message":"Hello!"}'
```
## 🚀 CI/CD
При создании тега (например, `v1.1.0`) автоматически:
1. Собираются бинарники для всех платформ
2. Создается Docker образ для Linux AMD64/ARM64
3. Образ публикуется в Docker Hub
4. Создается релиз в Gitea с бинарниками
## 📄 Лицензия
MIT License