mirror of
https://github.com/komari-monitor/komari.git
synced 2026-11-22 16:00:46 +00:00
Extract repeated frontend build, frontend restore, and Zig setup steps into shared GitHub Actions so CI workflows use the same artifact and toolchain setup path. Update binary and Docker builds to depend on the frontend artifact, and require an explicit Docker dispatch version for controlled image tagging.
76 lines
2.2 KiB
YAML
76 lines
2.2 KiB
YAML
name: Development Environment
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-binaries:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v4
|
|
|
|
#- name: Create dummy index.html
|
|
# run: |
|
|
# mkdir -p web/public/defaultTheme/dist
|
|
# echo "<html><body><h1>This is komari development server.</h1></body></html>" > web/public/defaultTheme/dist/index.html
|
|
|
|
- name: Clone and build frontend
|
|
uses: ./.github/actions/build-frontend
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: "1.23"
|
|
|
|
- name: Build application
|
|
env:
|
|
GOOS: linux
|
|
GOARCH: amd64
|
|
run: |
|
|
VERSION_SHA="${{ github.sha }}"
|
|
go build -ldflags "-X github.com/komari-monitor/komari/utils.CurrentVersion=dev -X github.com/komari-monitor/komari/utils.VersionHash=${VERSION_SHA}" -o komari .
|
|
|
|
- name: Upload binary as artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: komari
|
|
path: komari
|
|
|
|
deploy-to-production:
|
|
needs: build-binaries
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
PRODUCTION_SERVER: ${{ vars.PRODUCTION_SERVER }}
|
|
if: github.ref == 'refs/heads/dev'
|
|
|
|
steps:
|
|
- name: Download binary
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: komari
|
|
|
|
- name: Setup SSH Key
|
|
uses: webfactory/ssh-agent@v0.8.0
|
|
with:
|
|
ssh-private-key: ${{ secrets.PRODUCTION_SSH_KEY }}
|
|
|
|
- name: Add host to known hosts
|
|
run: |
|
|
mkdir -p ~/.ssh
|
|
ssh-keyscan -H ${{ env.PRODUCTION_SERVER }} >> ~/.ssh/known_hosts 2>/dev/null
|
|
|
|
- name: Deploy to production
|
|
run: |
|
|
chmod +x komari
|
|
ssh root@${{ env.PRODUCTION_SERVER }} 'mkdir -p /opt/komari/'
|
|
ssh root@${{ env.PRODUCTION_SERVER }} 'systemctl stop komari.service || true'
|
|
ssh root@${{ env.PRODUCTION_SERVER }} 'rm -f /opt/komari/komari.old'
|
|
ssh root@${{ env.PRODUCTION_SERVER }} 'mv /opt/komari/komari /opt/komari/komari.old || true'
|
|
scp komari root@${{ env.PRODUCTION_SERVER }}:/opt/komari/komari
|
|
ssh root@${{ env.PRODUCTION_SERVER }} 'systemctl start komari.service'
|