Compare commits
10 Commits
feature/ad
...
v0.10.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
56c51e5d02 | ||
|
|
1c57da9aba | ||
|
|
b2d88f1aa3 | ||
|
|
45d9681203 | ||
|
|
e259f2235a | ||
|
|
e575f641c5 | ||
|
|
bb75a8c325 | ||
|
|
99b1a2d1e9 | ||
|
|
a34b08072e | ||
|
|
8057420f09 |
@@ -8,13 +8,13 @@ env:
|
|||||||
GO_VERSION: "1.21"
|
GO_VERSION: "1.21"
|
||||||
BINARY_NAME: "acc-server-manager"
|
BINARY_NAME: "acc-server-manager"
|
||||||
MIGRATE_BINARY: "acc-server-migration"
|
MIGRATE_BINARY: "acc-server-migration"
|
||||||
API_BINARY: "api"
|
|
||||||
DEPLOY_PATH: 'C:\acc-server-manager'
|
DEPLOY_PATH: 'C:\acc-server-manager'
|
||||||
SERVICE_NAME: "ACC Server Manager"
|
SERVICE_NAME: "ACC Server Manager"
|
||||||
|
HEALTH_URL: "http://localhost:4000/v1/system/health"
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: windows-latest
|
runs-on: windows
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v3
|
||||||
@@ -27,35 +27,17 @@ jobs:
|
|||||||
go-version: ${{ env.GO_VERSION }}
|
go-version: ${{ env.GO_VERSION }}
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
env:
|
||||||
|
CGO_ENABLED: 1
|
||||||
run: go test -v ./...
|
run: go test -v ./...
|
||||||
|
|
||||||
- name: Build binaries
|
- name: Build binaries
|
||||||
|
env:
|
||||||
|
CGO_ENABLED: 1
|
||||||
run: |
|
run: |
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
go build -v -o ./build/${{ env.BINARY_NAME }}.exe ./cmd/server
|
go build -v -o ./build/${{ env.MIGRATE_BINARY }}.exe ./cmd/migrate
|
||||||
go build -v -o ./build/${{ env.MIGRATE_BINARY }}.exe ./cmd/migration
|
go build -v -o ./build/${{ env.BINARY_NAME }}.exe ./cmd/api
|
||||||
go build -v -o ./build/${{ env.API_BINARY }}.exe ./cmd/api
|
|
||||||
|
|
||||||
- name: Create release
|
|
||||||
id: create_release
|
|
||||||
uses: actions/create-release@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
tag_name: ${{ github.ref }}
|
|
||||||
release_name: Release ${{ github.ref }}
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
|
|
||||||
- name: Upload release assets
|
|
||||||
uses: actions/upload-release-asset@v1
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
with:
|
|
||||||
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
|
||||||
asset_path: ./build/
|
|
||||||
asset_name: acc-server-manager-${{ github.ref_name }}.zip
|
|
||||||
asset_content_type: application/zip
|
|
||||||
|
|
||||||
- name: Upload build artifacts
|
- name: Upload build artifacts
|
||||||
uses: actions/upload-artifact@v3
|
uses: actions/upload-artifact@v3
|
||||||
@@ -66,7 +48,7 @@ jobs:
|
|||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
needs: build
|
needs: build
|
||||||
runs-on: windows-latest
|
runs-on: windows
|
||||||
environment: production
|
environment: production
|
||||||
steps:
|
steps:
|
||||||
- name: Download build artifacts
|
- name: Download build artifacts
|
||||||
@@ -113,7 +95,8 @@ jobs:
|
|||||||
# Run database migrations
|
# Run database migrations
|
||||||
Write-Host "Running database migrations..."
|
Write-Host "Running database migrations..."
|
||||||
try {
|
try {
|
||||||
& "${{ env.DEPLOY_PATH }}\${{ env.MIGRATE_BINARY }}.exe"
|
& cd "${{ env.DEPLOY_PATH }}"
|
||||||
|
& ".\${{ env.MIGRATE_BINARY }}.exe"
|
||||||
} catch {
|
} catch {
|
||||||
Write-Warning "Migration failed: $_"
|
Write-Warning "Migration failed: $_"
|
||||||
throw "Migration failed"
|
throw "Migration failed"
|
||||||
@@ -153,7 +136,7 @@ jobs:
|
|||||||
|
|
||||||
while ($attempt -le $maxAttempts -and -not $success) {
|
while ($attempt -le $maxAttempts -and -not $success) {
|
||||||
try {
|
try {
|
||||||
$response = Invoke-WebRequest -Uri "http://localhost:8080/health" -TimeoutSec 5
|
$response = Invoke-WebRequest -Uri "${{ env.HEALTH_URL }}" -TimeoutSec 5
|
||||||
if ($response.StatusCode -eq 200) {
|
if ($response.StatusCode -eq 200) {
|
||||||
Write-Host "Health check passed!"
|
Write-Host "Health check passed!"
|
||||||
$success = $true
|
$success = $true
|
||||||
@@ -168,31 +151,3 @@ jobs:
|
|||||||
if (-not $success) {
|
if (-not $success) {
|
||||||
throw "Health check failed after $maxAttempts attempts"
|
throw "Health check failed after $maxAttempts attempts"
|
||||||
}
|
}
|
||||||
|
|
||||||
- name: Notify on success
|
|
||||||
if: success()
|
|
||||||
uses: actions/github-script@v6
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const { repo, owner } = context.repo;
|
|
||||||
const release = context.ref.replace('refs/tags/', '');
|
|
||||||
await github.rest.issues.createComment({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
issue_number: context.issue.number,
|
|
||||||
body: `✅ Successfully deployed ${release} to production!`
|
|
||||||
});
|
|
||||||
|
|
||||||
- name: Notify on failure
|
|
||||||
if: failure()
|
|
||||||
uses: actions/github-script@v6
|
|
||||||
with:
|
|
||||||
script: |
|
|
||||||
const { repo, owner } = context.repo;
|
|
||||||
const release = context.ref.replace('refs/tags/', '');
|
|
||||||
await github.rest.issues.createComment({
|
|
||||||
owner,
|
|
||||||
repo,
|
|
||||||
issue_number: context.issue.number,
|
|
||||||
body: `❌ Failed to deploy ${release} to production. Check the workflow logs for details.`
|
|
||||||
});
|
|
||||||
|
|||||||
@@ -20,7 +20,12 @@ func InitializeControllers(c *dig.Container) {
|
|||||||
logging.Panic("unable to initialize auth middleware")
|
logging.Panic("unable to initialize auth middleware")
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.Invoke(NewServiceControlController)
|
err := c.Invoke(NewSystemController)
|
||||||
|
if err != nil {
|
||||||
|
logging.Panic("unable to initialize system controller")
|
||||||
|
}
|
||||||
|
|
||||||
|
err = c.Invoke(NewServiceControlController)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logging.Panic("unable to initialize service control controller")
|
logging.Panic("unable to initialize service control controller")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package controller
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"acc-server-manager/local/utl/common"
|
"acc-server-manager/local/utl/common"
|
||||||
|
"acc-server-manager/local/utl/configs"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
)
|
)
|
||||||
@@ -34,5 +35,5 @@ func NewSystemController(routeGroups *common.RouteGroups) *SystemController {
|
|||||||
// @Success 200 {array} string
|
// @Success 200 {array} string
|
||||||
// @Router /v1/service-control [get]
|
// @Router /v1/service-control [get]
|
||||||
func (ac *SystemController) getFirst(c *fiber.Ctx) error {
|
func (ac *SystemController) getFirst(c *fiber.Ctx) error {
|
||||||
return c.SendStatus(fiber.StatusOK)
|
return c.SendString(configs.Version)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
Version = "0.0.1"
|
Version = "0.10.2"
|
||||||
Prefix = "v1"
|
Prefix = "v1"
|
||||||
Secret string
|
Secret string
|
||||||
SecretCode string
|
SecretCode string
|
||||||
|
|||||||
Reference in New Issue
Block a user