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
21 changes: 21 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,24 @@ jobs:
gh release create ${{ github.ref_name }} ./dist/* --notes "$changelog" --title ${{ github.ref_name }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ github.actor }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: |
${{ github.actor }}/sentinel:latest
${{ github.actor }}/sentinel:${{ github.ref_name }}
build-args: |
VERSION=${{ github.ref_name }}
COMMIT_HASH=${{ github.sha }}
67 changes: 67 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Test

on:
push:
branches: ["master"]
pull_request:
branches: ["master"]

jobs:
build-frontend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "24"

- name: Install dependencies
run: cd frontend && npm install -g pnpm

- name: Install frontend dependencies
run: cd frontend && pnpm install --frozen-lockfile

- name: Run format check
run: cd frontend && pnpm run format-check

- name: Build frontend
run: cd frontend && pnpm run build

- name: Upload frontend dist
uses: actions/upload-artifact@v4
with:
name: frontend-dist
path: frontend/dist/

# - name: Run lint
# run: pnpm run lint

build-backend:
runs-on: ubuntu-latest
needs: build-frontend
steps:
- uses: actions/checkout@v4

- name: Download frontend dist
uses: actions/download-artifact@v4
with:
name: frontend-dist
path: frontend/dist/

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: "1.24"

- name: Build
run: |-
go mod download
go build -v ./...

- name: Test
run: go test -v ./...
9 changes: 7 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ RUN pnpm run build
# Backend build stage
FROM golang:1.24-alpine AS backend-builder

# Define build arguments for version, commit, and date.
ARG VERSION=$(git describe --tags --abbrev=0 || echo "0.0.0")
ARG COMMIT_HASH=$(git rev-parse --short HEAD || echo "none")
ARG BUILD_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")

# Install dependencies
RUN apk add --no-cache ca-certificates

Expand All @@ -35,7 +40,7 @@ COPY . .
COPY --from=frontend-builder /app/frontend/dist ./frontend/dist

# Build the application with embedded frontend
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix -ldflags="-w -s" -o sentinel ./cmd/sentinel
RUN CGO_ENABLED=0 go build -a -installsuffix -ldflags="-w -s -X main.version=${VERSION} -X main.commitHash=${COMMIT_HASH} -X main.buildDate=${BUILD_DATE}" -o bin/sentinel ./cmd/sentinel

# Final stage
FROM alpine:latest
Expand All @@ -46,7 +51,7 @@ RUN apk --no-cache add ca-certificates tzdata
WORKDIR /root/

# Copy binary from builder stage
COPY --from=backend-builder /app/sentinel .
COPY --from=backend-builder /app/bin/sentinel .

# Run the binary
CMD ["./sentinel", "start"]
11 changes: 7 additions & 4 deletions frontend/orval.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// orval.config.ts
// This file is used to generate the API client using orval
export default {
import { defineConfig } from "orval";

export default defineConfig({
api: {
input: "../docs/docsv1/swagger.json", // путь к Swagger JSON
output: {
Expand All @@ -15,5 +15,8 @@ export default {
},
},
},
hooks: {
afterAllFilesWrite: "pnpm format",
},
},
};
});
1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"lint": "eslint .",
"preview": "vite preview",
"format": "prettier --config .prettierrc --write .",
"format-check": "prettier --config .prettierrc --check .",
"gen-api": "npx orval"
},
"dependencies": {
Expand Down
Loading