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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2

- name: Build Vue App
run: cd internal/admin/ui && npm ci && npm run build

- name: Cache go mod
uses: actions/cache@v2
with:
Expand Down Expand Up @@ -55,6 +58,9 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2

- name: Build Vue App
run: cd internal/admin/ui && npm ci && npm run build

- name: Cache go mod
uses: actions/cache@v2
with:
Expand Down
53 changes: 28 additions & 25 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,34 +38,37 @@ jobs:
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed

steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main
- name: Build Vue App
run: cd internal/admin/ui && npm ci && npm run build

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language
# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

#- run: |
# make bootstrap
# make release
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
3 changes: 3 additions & 0 deletions .github/workflows/staticcheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ jobs:
- name: Checkout Code
uses: actions/checkout@v2

- name: Build Vue App
run: cd internal/admin/ui && npm ci && npm run build

- name: Cache go mod
uses: actions/cache@v2
with:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Desktop.ini
# Build
build/
output/
dist/

# Config
config.yaml
26 changes: 26 additions & 0 deletions internal/admin/admin.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package admin

import (
"embed"
"io/fs"
"net/http"

"go.uber.org/zap"

"github.com/gorilla/mux"
)

//go:embed ui/dist
var adminUI embed.FS

func Serve(r *mux.Router, log *zap.Logger) {
sub, err := fs.Sub(adminUI, "ui/dist")
if err != nil {
log.Error("failed to get subtree for admin pages", zap.Error(err))
return
}

adminFS := http.FileServer(http.FS(sub))

r.PathPrefix("/admin").Handler(http.StripPrefix("/admin", adminFS))
}
3 changes: 2 additions & 1 deletion internal/admin/ui/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ import vue from '@vitejs/plugin-vue'

// https://vitejs.dev/config/
export default defineConfig({
plugins: [vue()]
plugins: [vue()],
base: '/admin/'
})
2 changes: 1 addition & 1 deletion internal/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *Server) setup() {
defer s.graceFullShutdown()

if !s.apiOnly {
web.Routes(s.router)
web.Routes(s.router, s.logger)
}

apiRouter := s.router.PathPrefix("/api").Subrouter()
Expand Down
10 changes: 7 additions & 3 deletions internal/server/web/web.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package web

import "github.com/gorilla/mux"

func Routes(r *mux.Router) {
import (
"github.com/aveloper/blog/internal/admin"
"github.com/gorilla/mux"
"go.uber.org/zap"
)

func Routes(r *mux.Router, log *zap.Logger) {
admin.Serve(r, log)
}
10 changes: 8 additions & 2 deletions scripts/build.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/bin/sh

echo "Building Admin UI"

cd internal/admin/ui && npm install && npm run build || exit 1

cd ../../.. || exit 1

echo "Running go generate"

go generate ./...
go generate ./... || exit 1

echo "Fetching latest version information"

# Fetch the latest to ensure we have the latest tag
git fetch origin
git fetch origin || exit 1

# Get the version from the git tag
# If not available, default to v0.0.0
Expand Down