Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
40df700
add kamal
sethhorsley Oct 17, 2025
1896d08
add healthcheck
sethhorsley Oct 17, 2025
02694df
add kamal with next.rubyui.com
sethhorsley Oct 18, 2025
46a1f69
Merge branch 'main' into add-kamal
sethhorsley Oct 18, 2025
4e0e67e
add blocks dynamic endpoint with iframe and update sidebar
sethhorsley Nov 4, 2025
a12f8a1
add proper blocks
sethhorsley Nov 5, 2025
c51867c
Merge branch 'main' into add-kamal
sethhorsley Nov 20, 2025
2c1b55f
🍸
sethhorsley Nov 20, 2025
1a3e21c
fix node version
sethhorsley Nov 20, 2025
0c5b66b
add nested sidebar
kashiftariq1997 Feb 11, 2026
8429d24
Add gemspec and Rails generators for ruby_ui gem
sethhorsley Mar 9, 2026
220424c
update ruby
sethhorsley Mar 9, 2026
95247f9
Merge branch 'main' into add-blocks
sethhorsley Mar 9, 2026
5b7af72
🍈
sethhorsley Mar 9, 2026
18eff3a
Merge branch 'add-blocks' into add-gemspec
sethhorsley Mar 9, 2026
4d8d526
Merge branch 'add-gemspec' into new-component-preview-components
sethhorsley Mar 9, 2026
684fa6e
update ruby
sethhorsley Mar 9, 2026
e19ef90
Merge branch 'main' into new-component-preview-components
sethhorsley Mar 9, 2026
9afcb2f
⚾️
sethhorsley Mar 9, 2026
14fc782
Merge branch 'main' into add-gemspec
sethhorsley Mar 9, 2026
9e45f1a
standard rb
sethhorsley Mar 9, 2026
d864489
🐍
sethhorsley Mar 9, 2026
95edb70
🥃
sethhorsley Mar 9, 2026
1ea9c49
Refactor RubyUI generators to ensure compatibility with Rails loading
sethhorsley Mar 9, 2026
84ac7f1
😃
sethhorsley Mar 9, 2026
3976b69
Merge pull request #14 from sethhorsley/add-gemspec
sethhorsley Mar 9, 2026
e8ff07f
Merge branch 'main' into new-component-preview-components
sethhorsley Mar 9, 2026
f67b0f9
🏌
sethhorsley Mar 9, 2026
df9d6ee
Merge branch 'main' into add-kamal
sethhorsley Mar 9, 2026
2ca416f
🐄
sethhorsley Mar 9, 2026
ad24d5b
👒
sethhorsley Mar 9, 2026
db769f5
🎩
sethhorsley Mar 9, 2026
3a234ff
🌟
sethhorsley Mar 9, 2026
1491e7c
📺
sethhorsley Mar 9, 2026
01b35f9
⛺️
sethhorsley Mar 9, 2026
bcd0806
😛
sethhorsley Mar 9, 2026
cc12630
🎷
sethhorsley Mar 9, 2026
0e62be0
Merge pull request #16 from sethhorsley/add-kamal
sethhorsley Mar 9, 2026
35960f0
fix deploy creds
sethhorsley Mar 9, 2026
33b1b0c
fix url
sethhorsley Mar 9, 2026
5cb78fe
fix host for kamal deploy
sethhorsley Mar 9, 2026
1ee131a
2nd try for kamal to work
sethhorsley Mar 9, 2026
9b9bf01
🔮
sethhorsley Mar 9, 2026
8a0b9ac
fix commit badge
sethhorsley Mar 9, 2026
7ffd249
Merge branch 'main' into feature/add-nested-sidebar
sethhorsley Mar 9, 2026
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,6 @@ jobs:
- name: Build and run dev container task
uses: devcontainers/ci@v0.3
with:
imageName: ghcr.io/ruby-ui/web-devcontainer
cacheFrom: ghcr.io/ruby-ui/web-devcontainer
imageName: ghcr.io/seth-ruby-ui/web-devcontainer
cacheFrom: ghcr.io/seth-ruby-ui/web-devcontainer
push: always
67 changes: 67 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Deploy with Kamal

on:
push:
branches:
- main
workflow_dispatch: # Allow manual trigger

jobs:
deploy:
runs-on: ubuntu-latest

# Only deploy if tests pass
needs: []

permissions:
contents: read
packages: write

steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: '4.0.1'
bundler-cache: true

- name: Install Kamal
run: gem install kamal

- name: Set up Docker Buildx for cache
uses: docker/setup-buildx-action@v3

- name: Expose GitHub Runtime for cache
uses: crazy-max/ghaction-github-runtime@v3

- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.KAMAL_REGISTRY_USERNAME }}
password: ${{ secrets.KAMAL_REGISTRY_PASSWORD }}

- name: Set up SSH connection
run: |
mkdir -p ~/.ssh && echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/id_rsa && chmod 600 ~/.ssh/id_rsa
eval $(ssh-agent -s) && ssh-add ~/.ssh/id_rsa
ssh-keyscan 45.55.81.54 >> ~/.ssh/known_hosts
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Create Kamal secrets file
run: |
mkdir -p .kamal
cat << EOF > .kamal/secrets
RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_KEY }}
KAMAL_REGISTRY_USERNAME=${{ secrets.KAMAL_REGISTRY_USERNAME }}
KAMAL_REGISTRY_PASSWORD=${{ secrets.KAMAL_REGISTRY_PASSWORD }}
EOF

- name: Deploy with Kamal
run: bin/kamal deploy
env:
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
KAMAL_REGISTRY_PASSWORD: ${{ secrets.KAMAL_REGISTRY_PASSWORD }}
KAMAL_REGISTRY_USERNAME: ${{ secrets.KAMAL_REGISTRY_USERNAME }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,8 @@ yarn-error.log

# Pnpm
.pnpm-store

# Ignore key files for decrypting credentials and more.
/config/credentials/*.key

.env
3 changes: 3 additions & 0 deletions .kamal/hooks/docker-setup.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

echo "Docker set up on $KAMAL_HOSTS..."
3 changes: 3 additions & 0 deletions .kamal/hooks/post-app-boot.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

echo "Booted app version $KAMAL_VERSION on $KAMAL_HOSTS..."
14 changes: 14 additions & 0 deletions .kamal/hooks/post-deploy.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh

# A sample post-deploy hook
#
# These environment variables are available:
# KAMAL_RECORDED_AT
# KAMAL_PERFORMER
# KAMAL_VERSION
# KAMAL_HOSTS
# KAMAL_ROLES (if set)
# KAMAL_DESTINATION (if set)
# KAMAL_RUNTIME

echo "$KAMAL_PERFORMER deployed $KAMAL_VERSION to $KAMAL_DESTINATION in $KAMAL_RUNTIME seconds"
3 changes: 3 additions & 0 deletions .kamal/hooks/post-proxy-reboot.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

echo "Rebooted kamal-proxy on $KAMAL_HOSTS"
3 changes: 3 additions & 0 deletions .kamal/hooks/pre-app-boot.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

echo "Booting app version $KAMAL_VERSION on $KAMAL_HOSTS..."
51 changes: 51 additions & 0 deletions .kamal/hooks/pre-build.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#!/bin/sh

# A sample pre-build hook
#
# Checks:
# 1. We have a clean checkout
# 2. A remote is configured
# 3. The branch has been pushed to the remote
# 4. The version we are deploying matches the remote
#
# These environment variables are available:
# KAMAL_RECORDED_AT
# KAMAL_PERFORMER
# KAMAL_VERSION
# KAMAL_HOSTS
# KAMAL_ROLES (if set)
# KAMAL_DESTINATION (if set)

if [ -n "$(git status --porcelain)" ]; then
echo "Git checkout is not clean, aborting..." >&2
git status --porcelain >&2
exit 1
fi

first_remote=$(git remote)

if [ -z "$first_remote" ]; then
echo "No git remote set, aborting..." >&2
exit 1
fi

current_branch=$(git branch --show-current)

if [ -z "$current_branch" ]; then
echo "Not on a git branch, aborting..." >&2
exit 1
fi

remote_head=$(git ls-remote $first_remote --tags $current_branch | cut -f1)

if [ -z "$remote_head" ]; then
echo "Branch not pushed to remote, aborting..." >&2
exit 1
fi

if [ "$KAMAL_VERSION" != "$remote_head" ]; then
echo "Version ($KAMAL_VERSION) does not match remote HEAD ($remote_head), aborting..." >&2
exit 1
fi

exit 0
47 changes: 47 additions & 0 deletions .kamal/hooks/pre-connect.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/usr/bin/env ruby

# A sample pre-connect check
#
# Warms DNS before connecting to hosts in parallel
#
# These environment variables are available:
# KAMAL_RECORDED_AT
# KAMAL_PERFORMER
# KAMAL_VERSION
# KAMAL_HOSTS
# KAMAL_ROLES (if set)
# KAMAL_DESTINATION (if set)
# KAMAL_RUNTIME

hosts = ENV["KAMAL_HOSTS"].split(",")
results = nil
max = 3

elapsed = Benchmark.realtime do
results = hosts.map do |host|
Thread.new do
tries = 1

begin
Socket.getaddrinfo(host, 0, Socket::AF_UNSPEC, Socket::SOCK_STREAM, nil, Socket::AI_CANONNAME)
rescue SocketError
if tries < max
puts "Retrying DNS warmup: #{host}"
tries += 1
sleep rand
retry
else
puts "DNS warmup failed: #{host}"
host
end
end

tries
end
end.map(&:value)
end

retries = results.sum - hosts.size
nopes = results.count { |r| r == max }

puts "Prewarmed %d DNS lookups in %.2f sec: %d retries, %d failures" % [ hosts.size, elapsed, retries, nopes ]
122 changes: 122 additions & 0 deletions .kamal/hooks/pre-deploy.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/usr/bin/env ruby

# A sample pre-deploy hook
#
# Checks the Github status of the build, waiting for a pending build to complete for up to 720 seconds.
#
# Fails unless the combined status is "success"
#
# These environment variables are available:
# KAMAL_RECORDED_AT
# KAMAL_PERFORMER
# KAMAL_VERSION
# KAMAL_HOSTS
# KAMAL_COMMAND
# KAMAL_SUBCOMMAND
# KAMAL_ROLES (if set)
# KAMAL_DESTINATION (if set)

# Only check the build status for production deployments
if ENV["KAMAL_COMMAND"] == "rollback" || ENV["KAMAL_DESTINATION"] != "production"
exit 0
end

require "bundler/inline"

# true = install gems so this is fast on repeat invocations
gemfile(true, quiet: true) do
source "https://rubygems.org"

gem "octokit"
gem "faraday-retry"
end

MAX_ATTEMPTS = 72
ATTEMPTS_GAP = 10

def exit_with_error(message)
$stderr.puts message
exit 1
end

class GithubStatusChecks
attr_reader :remote_url, :git_sha, :github_client, :combined_status

def initialize
@remote_url = github_repo_from_remote_url
@git_sha = `git rev-parse HEAD`.strip
@github_client = Octokit::Client.new(access_token: ENV["GITHUB_TOKEN"])
refresh!
end

def refresh!
@combined_status = github_client.combined_status(remote_url, git_sha)
end

def state
combined_status[:state]
end

def first_status_url
first_status = combined_status[:statuses].find { |status| status[:state] == state }
first_status && first_status[:target_url]
end

def complete_count
combined_status[:statuses].count { |status| status[:state] != "pending"}
end

def total_count
combined_status[:statuses].count
end

def current_status
if total_count > 0
"Completed #{complete_count}/#{total_count} checks, see #{first_status_url} ..."
else
"Build not started..."
end
end

private
def github_repo_from_remote_url
url = `git config --get remote.origin.url`.strip.delete_suffix(".git")
if url.start_with?("https://github.com/")
url.delete_prefix("https://github.com/")
elsif url.start_with?("git@github.com:")
url.delete_prefix("git@github.com:")
else
url
end
end
end


$stdout.sync = true

begin
puts "Checking build status..."

attempts = 0
checks = GithubStatusChecks.new

loop do
case checks.state
when "success"
puts "Checks passed, see #{checks.first_status_url}"
exit 0
when "failure"
exit_with_error "Checks failed, see #{checks.first_status_url}"
when "pending"
attempts += 1
end

exit_with_error "Checks are still pending, gave up after #{MAX_ATTEMPTS * ATTEMPTS_GAP} seconds" if attempts == MAX_ATTEMPTS

puts checks.current_status
sleep(ATTEMPTS_GAP)
checks.refresh!
end
rescue Octokit::NotFound
exit_with_error "Build status could not be found"
end
3 changes: 3 additions & 0 deletions .kamal/hooks/pre-proxy-reboot.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh

echo "Rebooting kamal-proxy on $KAMAL_HOSTS..."
20 changes: 20 additions & 0 deletions .kamal/secrets
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Secrets defined here are available for reference under registry/password, env/secret, builder/secrets,
# and accessories/*/env/secret in config/deploy.yml. All secrets should be pulled from either
# password manager, ENV, or a file. DO NOT ENTER RAW CREDENTIALS HERE! This file needs to be safe for git.

# Rails master key
RAILS_MASTER_KEY=$(cat config/credentials/production.key)

# Registry credentials
# These should be set in your .env file or environment
# KAMAL_REGISTRY_USERNAME and KAMAL_REGISTRY_PASSWORD are read from ENV
KAMAL_REGISTRY_USERNAME=$KAMAL_REGISTRY_USERNAME
KAMAL_REGISTRY_PASSWORD=$KAMAL_REGISTRY_PASSWORD

# Option 3: Read secrets via kamal secrets helpers
# These will handle logging in and fetching the secrets in as few calls as possible
# There are adapters for 1Password, LastPass + Bitwarden
#
# SECRETS=$(kamal secrets fetch --adapter 1password --account my-account --from MyVault/MyItem KAMAL_REGISTRY_PASSWORD RAILS_MASTER_KEY)
# KAMAL_REGISTRY_PASSWORD=$(kamal secrets extract KAMAL_REGISTRY_PASSWORD $SECRETS)
# RAILS_MASTER_KEY=$(kamal secrets extract RAILS_MASTER_KEY $SECRETS)
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3.4.7
4.0.1
Loading
Loading