Skip to content

Commit

Permalink
Merge with main
Browse files Browse the repository at this point in the history
  • Loading branch information
Meri-MG committed Dec 17, 2024
2 parents 7c79899 + fcab2a2 commit 472d2cd
Show file tree
Hide file tree
Showing 308 changed files with 5,179 additions and 2,535 deletions.
81 changes: 81 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -556,6 +556,87 @@
"contributions": [
"code"
]
},
{
"login": "wiliajc87",
"name": "Jordy Williams",
"avatar_url": "https://avatars.githubusercontent.com/u/8497806?v=4",
"profile": "https://github.com/wiliajc87",
"contributions": [
"code"
]
},
{
"login": "tamirazrab",
"name": "Tamir",
"avatar_url": "https://avatars.githubusercontent.com/u/38686510?v=4",
"profile": "https://github.com/tamirazrab",
"contributions": [
"code"
]
},
{
"login": "palidii",
"name": "palidii",
"avatar_url": "https://avatars.githubusercontent.com/u/150976749?v=4",
"profile": "https://github.com/palidii",
"contributions": [
"code"
]
},
{
"login": "Isaac3924",
"name": "Isaac Alter",
"avatar_url": "https://avatars.githubusercontent.com/u/17149928?v=4",
"profile": "https://github.com/Isaac3924",
"contributions": [
"code"
]
},
{
"login": "fivefootbot",
"name": "Amy McCaughan",
"avatar_url": "https://avatars.githubusercontent.com/u/149846643?v=4",
"profile": "https://github.com/fivefootbot",
"contributions": [
"code"
]
},
{
"login": "jrussell416",
"name": "jrussell416",
"avatar_url": "https://avatars.githubusercontent.com/u/58918229?v=4",
"profile": "https://github.com/jrussell416",
"contributions": [
"code"
]
},
{
"login": "caitlynl22",
"name": "Caitlyn Landry",
"avatar_url": "https://avatars.githubusercontent.com/u/8726946?v=4",
"profile": "https://github.com/caitlynl22",
"contributions": [
"code"
]
},
{
"login": "jasonwang7517",
"name": "Jason Wang",
"avatar_url": "https://avatars.githubusercontent.com/u/39580712?v=4",
"profile": "https://www.linkedin.com/in/jasonwang7517/",
"contributions": [
"code"
]
},
{
"login": "mgrigoriev8109",
"name": "Mikhail Grigoriev",
"avatar_url": "https://avatars.githubusercontent.com/u/43343880?v=4",
"profile": "https://github.com/mgrigoriev8109",
"contributions": [
"code"
]
}
],
"contributorsPerLine": 7,
Expand Down
58 changes: 58 additions & 0 deletions .annotaterb.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
:position: before
:position_in_additional_file_patterns: before
:position_in_class: before
:position_in_factory: before
:position_in_fixture: before
:position_in_routes: before
:position_in_serializer: before
:position_in_test: before
:classified_sort: true
:exclude_controllers: true
:exclude_factories: true
:exclude_fixtures: true
:exclude_helpers: true
:exclude_scaffolds: true
:exclude_serializers: false
:exclude_sti_subclasses: false
:exclude_tests: true
:force: false
:format_markdown: false
:format_rdoc: false
:format_yard: false
:frozen: false
:ignore_model_sub_dir: false
:ignore_unknown_models: false
:include_version: false
:show_check_constraints: false
:show_complete_foreign_keys: false
:show_foreign_keys: true
:show_indexes: true
:simple_indexes: false
:sort: false
:timestamp: false
:trace: false
:with_comment: true
:with_column_comments: true
:with_table_comments: true
:active_admin: false
:command:
:debug: false
:hide_default_column_types: ''
:hide_limit_column_types: ''
:ignore_columns:
:ignore_routes:
:models: true
:routes: false
:skip_on_db_migrate: false
:target_action: :do_annotations
:wrapper:
:wrapper_close:
:wrapper_open:
:classes_default_to_s: []
:additional_file_patterns: []
:model_dir:
- app/models
:require: []
:root_dir:
- ''
79 changes: 79 additions & 0 deletions .github/workflows/kamaldeploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: Kamal Deployment

on:
workflow_dispatch:
schedule:
- cron: "0 21 * * 2" # runs Tuesdays at 21:00 UTC

jobs:
check_latest_commit:
runs-on: ubuntu-latest

outputs:
commit_sha: ${{ env.SHA }}

steps:
- name: Checkout the latest commit on main
uses: actions/checkout@v4
with:
ref: main

- name: Get the latest commit SHA
run: echo "SHA=$(git rev-parse HEAD)" >> $GITHUB_ENV

- name: Confirm all checks passed
run: |
# Returns json data on all checks that were run
response=$(curl -L \
-H "Accept: application/vnd.github+json" \
"https://api.github.com/repos/${{ github.repository }}/commits/${{ env.SHA }}/check-runs")
# Check the conclusion of eash check for pass/fail
for conclusion in $(echo "$response" | jq -r '.check_runs[] | select(.name != "deploy" and .name != "check_latest_commit") | .conclusion'); do
if [ "$conclusion" != "success" ]; then
echo "Commit "${{ env.SHA }}" has failed checks."
exit 1
fi
done
deploy:
runs-on: ubuntu-latest
needs: check_latest_commit

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
ref: main

- name: Install Ruby and gems
uses: ruby/setup-ruby@v1
with:
bundler-cache: true

- name: Install Kamal
run: gem install kamal

- name: Set up SSH
env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
RAILS_MASTER_KEY: ${{ secrets.RAILS_MASTER_KEY }}
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/homewardtails.pem
echo "$RAILS_MASTER_KEY" > config/credentials/production.key
chmod 600 ~/.ssh/homewardtails.pem
ssh-keyscan homewardtails.org >> ~/.ssh/known_hosts || echo "failed"
- name: Check if latest commit is running in production
run: |
RUNNING_APP_SHA=$(kamal app version | grep . | tail -n 1)
# Compare the current running SHA to the latest commit SHA
if [ "$RUNNING_APP_SHA" == "${{ needs.check_latest_commit.outputs.commit_sha }}" ]; then
echo "Running version is up to date, skipping deployment."
exit 0
fi
- name: Kamal Deploy
run: kamal deploy
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,8 @@

# OS
.DS_Store

/config/credentials/production.key

# LazyVim config file
.lazy.lua
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..."
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_ROLE (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"
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_ROLE (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_ROLE (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 ]
Loading

0 comments on commit 472d2cd

Please sign in to comment.