Compare commits

...

3 Commits

Author SHA1 Message Date
Techno Tim b86698f06c
Merge d84c00af94 into 584768bacf 2025-07-10 21:35:30 -04:00
Aveline 584768bacf
chore: remove /device/ui-config.js endpoint (#678) 2025-07-10 12:04:47 +02:00
Timothy Stewart d84c00af94 feat(ci): GitHub action for pull requests - Go + NodeJS 2025-02-23 22:59:56 -06:00
2 changed files with 75 additions and 18 deletions

75
.github/workflows/pull-request.yaml vendored Normal file
View File

@ -0,0 +1,75 @@
name: 'Pull Request'
on:
pull_request:
branches:
- dev
paths-ignore:
- .gitignore
- README.md
- LICENSE
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: v21.1.0
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- name: Cache NPM dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-cache-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-cache-${{ runner.os }}-
- name: Install Dependencies and Build
run: |
cd ui
npm ci
# npm run lint # need to clean lint before enabling this
npm run build:prod
env:
CI: true
- name: Cache Prisma Binary
uses: actions/cache@v4
with:
path: ~/.npm/_npx
key: prisma-binary-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
restore-keys: prisma-binary-${{ runner.os }}-
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.24.0'
- name: Cache Go modules
id: cache-go-mod
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install dependencies
run: go mod download
- name: Build Go application
env:
GOOS: linux
GOARCH: arm
GOARM: 7
VERSION_DEV: ci-build
run: |
make frontend
make build_dev

18
web.go
View File

@ -97,9 +97,6 @@ func setupRouter() *gin.Engine {
// We use this to determine if the device is setup // We use this to determine if the device is setup
r.GET("/device/status", handleDeviceStatus) r.GET("/device/status", handleDeviceStatus)
// We use this to provide the UI with the device configuration
r.GET("/device/ui-config.js", handleDeviceUIConfig)
// We use this to setup the device in the welcome page // We use this to setup the device in the welcome page
r.POST("/device/setup", handleSetup) r.POST("/device/setup", handleSetup)
@ -694,21 +691,6 @@ func handleCloudState(c *gin.Context) {
c.JSON(http.StatusOK, response) c.JSON(http.StatusOK, response)
} }
func handleDeviceUIConfig(c *gin.Context) {
config, _ := json.Marshal(gin.H{
"CLOUD_API": config.CloudURL,
"DEVICE_VERSION": builtAppVersion,
})
if config == nil {
c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to marshal config"})
return
}
response := fmt.Sprintf("window.JETKVM_CONFIG = %s;", config)
c.Data(http.StatusOK, "text/javascript; charset=utf-8", []byte(response))
}
func handleSetup(c *gin.Context) { func handleSetup(c *gin.Context) {
// Check if the device is already set up // Check if the device is already set up
if config.LocalAuthMode != "" || config.HashedPassword != "" { if config.LocalAuthMode != "" || config.HashedPassword != "" {