From 26907c67126301b5f049ffa000c61330555caf24 Mon Sep 17 00:00:00 2001 From: Pham Le Gia Dai Date: Sun, 11 Jan 2026 21:05:20 +0700 Subject: [PATCH 1/4] fix: ensure CI triggers on version tags --- .github/workflows/ci.yml | 120 +++++++++++++++++++-------------------- 1 file changed, 58 insertions(+), 62 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa785d2..1049fa7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,65 +1,61 @@ -name: CI +name: ci on: - push: - branches: [main] - pull_request: - branches: [main] - + push: + branches: + - master + pull_request: + branches: + - master jobs: - test: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Go - uses: actions/setup-go@v5 - with: - go-version-file: go.mod - - - name: Format check - run: | - unformatted=$(gofmt -l .) - if [ -n "$unformatted" ]; then - echo "gofmt needed on:" - echo "$unformatted" - exit 1 - fi - - - name: Test - run: go test ./... - - docker: - runs-on: ubuntu-latest - needs: test - if: github.event_name == 'pull_request' || startsWith(github.ref, 'refs/tags/') - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v3 - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Docker metadata - id: meta - uses: docker/metadata-action@v5 - with: - images: daipham3213/mux0.dev - tags: | - type=ref,event=pr - type=ref,event=tag - - - name: Build and push - uses: docker/build-push-action@v6 - with: - context: . - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} + golangci: + permissions: + contents: read # for actions/checkout to fetch code + pull-requests: read # for golangci/golangci-lint-action to fetch pull requests + name: lint + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v5 + - name: Install Go + uses: actions/setup-go@v6 + with: + go-version: ">=1.24" + - name: golangci-lint + uses: golangci/golangci-lint-action@v9 + with: + version: v2.6 + build: + needs: golangci + name: build + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ vars.HUBUSERNAME }} + password: ${{ vars.HUBTOKEN }} + + - name: Docker metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: daipham3213/mux0.dev + tags: | + type=ref,event=pr + type=ref,event=tag + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file From 0c25ff24677c497c3cbf37861a6eeb939b76f8de Mon Sep 17 00:00:00 2001 From: Pham Le Gia Dai Date: Sun, 11 Jan 2026 21:42:20 +0700 Subject: [PATCH 2/4] fix: improve error handling and context key usage in SSH and TUI components --- cmd/ssh/main.go | 5 ++++- pkg/tui/root.go | 8 ++++--- pkg/tui/theme/huh.go | 50 +++++++++++++++++++++--------------------- pkg/tui/theme/theme.go | 2 +- 4 files changed, 35 insertions(+), 30 deletions(-) diff --git a/cmd/ssh/main.go b/cmd/ssh/main.go index f005aaa..8559ee7 100644 --- a/cmd/ssh/main.go +++ b/cmd/ssh/main.go @@ -75,6 +75,7 @@ func main() { ) if err != nil { log.Error("Could not start server", "error", err) + return } log.Info("Starting SSH server", "port", addr) @@ -103,7 +104,9 @@ func main() { }() <-ctx.Done() - srv.Shutdown(ctx) + if err := srv.Shutdown(ctx); err != nil && !errors.Is(err, ssh.ErrServerClosed) { + log.Error("Could not shutdown server", "error", err) + } slog.Info("Shutting down server") } diff --git a/pkg/tui/root.go b/pkg/tui/root.go index 35b2ecf..8244f9d 100644 --- a/pkg/tui/root.go +++ b/pkg/tui/root.go @@ -22,6 +22,10 @@ const ( large ) +type contextKey string + +const clientIPKey contextKey = "client_ip" + type sectionItem struct { id string title string @@ -48,8 +52,6 @@ type model struct { viewportHeight int widthContainer int heightContainer int - widthContent int - heightContent int size size theme theme.Theme showSplash bool @@ -68,7 +70,7 @@ func NewModel( command []string, ) (tea.Model, error) { ctx := context.Background() - ctx = context.WithValue(ctx, "client_ip", clientIP) + ctx = context.WithValue(ctx, clientIPKey, clientIP) p := portfolio.Default() th := theme.BasicTheme(renderer, nil) diff --git a/pkg/tui/theme/huh.go b/pkg/tui/theme/huh.go index 20df43d..e02b0dc 100644 --- a/pkg/tui/theme/huh.go +++ b/pkg/tui/theme/huh.go @@ -7,37 +7,37 @@ import ( // copy returns a copy of a TextInputStyles with all children styles copied. func copyTextStyles(t huh.TextInputStyles) huh.TextInputStyles { return huh.TextInputStyles{ - Cursor: t.Cursor.Copy(), - Placeholder: t.Placeholder.Copy(), - Prompt: t.Prompt.Copy(), - Text: t.Text.Copy(), + Cursor: t.Cursor, + Placeholder: t.Placeholder, + Prompt: t.Prompt, + Text: t.Text, } } // copy returns a copy of a FieldStyles with all children styles copied. func copyFieldStyles(f huh.FieldStyles) huh.FieldStyles { return huh.FieldStyles{ - Base: f.Base.Copy(), - Title: f.Title.Copy(), - Description: f.Description.Copy(), - ErrorIndicator: f.ErrorIndicator.Copy(), - ErrorMessage: f.ErrorMessage.Copy(), - SelectSelector: f.SelectSelector.Copy(), - // NextIndicator: f.NextIndicator.Copy(), - // PrevIndicator: f.PrevIndicator.Copy(), - Option: f.Option.Copy(), - // Directory: f.Directory.Copy(), - // File: f.File.Copy(), - MultiSelectSelector: f.MultiSelectSelector.Copy(), - SelectedOption: f.SelectedOption.Copy(), - SelectedPrefix: f.SelectedPrefix.Copy(), - UnselectedOption: f.UnselectedOption.Copy(), - UnselectedPrefix: f.UnselectedPrefix.Copy(), - FocusedButton: f.FocusedButton.Copy(), - BlurredButton: f.BlurredButton.Copy(), + Base: f.Base, + Title: f.Title, + Description: f.Description, + ErrorIndicator: f.ErrorIndicator, + ErrorMessage: f.ErrorMessage, + SelectSelector: f.SelectSelector, + // NextIndicator: f.NextIndicator, + // PrevIndicator: f.PrevIndicator, + Option: f.Option, + // Directory: f.Directory, + // File: f.File, + MultiSelectSelector: f.MultiSelectSelector, + SelectedOption: f.SelectedOption, + SelectedPrefix: f.SelectedPrefix, + UnselectedOption: f.UnselectedOption, + UnselectedPrefix: f.UnselectedPrefix, + FocusedButton: f.FocusedButton, + BlurredButton: f.BlurredButton, TextInput: copyTextStyles(f.TextInput), - Card: f.Card.Copy(), - NoteTitle: f.NoteTitle.Copy(), - Next: f.Next.Copy(), + Card: f.Card, + NoteTitle: f.NoteTitle, + Next: f.Next, } } diff --git a/pkg/tui/theme/theme.go b/pkg/tui/theme/theme.go index de24257..46c59f4 100644 --- a/pkg/tui/theme/theme.go +++ b/pkg/tui/theme/theme.go @@ -92,7 +92,7 @@ func (b Theme) Accent() lipgloss.TerminalColor { } func (b Theme) Base() lipgloss.Style { - return b.base.Copy() + return b.base } func (b Theme) TextBody() lipgloss.Style { From ab0780e124fe6ee7c03cb04544c1c3f8217e8065 Mon Sep 17 00:00:00 2001 From: Pham Le Gia Dai Date: Sun, 11 Jan 2026 21:44:37 +0700 Subject: [PATCH 3/4] fix: update CI build condition to trigger on pull requests --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1049fa7..3fbce40 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -28,7 +28,7 @@ jobs: build: needs: golangci name: build - if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') + if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') || github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - name: Checkout @@ -40,8 +40,8 @@ jobs: - name: Login to Docker Hub uses: docker/login-action@v3 with: - username: ${{ vars.HUBUSERNAME }} - password: ${{ vars.HUBTOKEN }} + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Docker metadata id: meta From ca7d8c66f88d02404c2017e7095036d3bf34cbb7 Mon Sep 17 00:00:00 2001 From: Pham Le Gia Dai Date: Sun, 11 Jan 2026 21:56:01 +0700 Subject: [PATCH 4/4] fix: add SSH_HOST_KEY handling in CI and Dockerfile --- .github/workflows/ci.yml | 2 ++ Dockerfile | 1 + 2 files changed, 3 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3fbce40..e7c3852 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -57,5 +57,7 @@ jobs: with: context: . push: true + secret-envs: | + SSH_HOST_KEY=${{ secrets.SSH_HOST_KEY }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index cabef49..a0f0fe9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -14,6 +14,7 @@ COPY index.html . RUN if [ -n "$SSH_HOST_KEY" ]; then \ echo "$SSH_HOST_KEY" > /app/host_key; \ else \ + apk add --no-cache openssh && \ ssh-keygen -t rsa -b 2048 -f /app/host_key -N ""; \ fi && \ chmod 600 /app/host_key