Skip to content

Support subpaths/projects per stack #1368

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion app/controllers/shipit/stacks_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def load_stack
end

def create_params
params.require(:stack).permit(:repo_owner, :repo_name, :environment, :branch, :deploy_url, :ignore_ci)
params.require(:stack).permit(:repo_owner, :repo_name, :environment, :branch, :deploy_url, :ignore_ci, :path)
end

def update_params
Expand Down
2 changes: 1 addition & 1 deletion app/models/shipit/stack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def github_repo_name

def github_commits
handle_github_redirections do
github_api.commits(github_repo_name, sha: branch)
github_api.commits(github_repo_name, sha: branch, path: path)
end
rescue Octokit::Conflict
[] # Repository is empty...
Expand Down
6 changes: 6 additions & 0 deletions app/views/shipit/stacks/_settings_form.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@
<span>Branch: <%= stack.branch %></span>
</div>

<% if stack.path.present? %>
<div class="field-wrapper">
<span>Path: <%= stack.path %></span>
</div>
<% end %>

<div class="field-wrapper">
<%= f.label :deploy_url, 'Deploy URL (Where is this stack deployed to?)' %>
<%= f.text_field :deploy_url, placeholder: 'https://' %>
Expand Down
5 changes: 5 additions & 0 deletions app/views/shipit/stacks/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
<%= f.label :environment %>
<%= f.text_field :environment, placeholder: 'production' %>
</div>
<div class="field-wrapper">
<%= f.label :path %>
<span class="form-hint"><small>Only track a subpath of this repo?</small></span>
<%= f.text_field :path, placeholder: '/' %>
</div>
<div class="field-wrapper">
<%= f.label :deploy_url %>
<span class="form-hint"><small>Where is this stack deployed to?</small></span>
Expand Down
5 changes: 5 additions & 0 deletions db/migrate/20240919171423_add_path_to_stack.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddPathToStack < ActiveRecord::Migration[7.2]
def change
add_column :stacks, :path, :string
end
end
1 change: 1 addition & 0 deletions dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ up:
- packages:
- sqlite
- ruby
- redis
- isogun
- bundler:
without: ci
Expand Down
2 changes: 1 addition & 1 deletion lib/shipit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def app_name
end

def redis_url
secrets.redis_url.present? ? URI(secrets.redis_url) : nil
secrets.redis_url.present? ? URI(secrets.redis_url) : ENV["REDIS_URL"]
end

def redis
Expand Down
13 changes: 6 additions & 7 deletions test/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2023_07_03_181143) do

ActiveRecord::Schema[7.2].define(version: 2024_09_19_171423) do
create_table "api_clients", force: :cascade do |t|
t.text "permissions", limit: 65535
t.integer "creator_id", limit: 4
Expand Down Expand Up @@ -197,8 +196,8 @@
t.integer "user_id"
t.text "labels"
t.integer "head_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.index ["head_id"], name: "index_pull_requests_on_head_id"
t.index ["stack_id", "github_id"], name: "index_pull_requests_on_stack_id_and_github_id", unique: true
t.index ["stack_id", "number"], name: "index_pull_requests_on_stack_id_and_number", unique: true
Expand All @@ -223,8 +222,8 @@
create_table "repositories", force: :cascade do |t|
t.string "owner", limit: 39, null: false
t.string "name", limit: 100, null: false
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.boolean "review_stacks_enabled", default: false
t.string "provisioning_behavior", default: "allow_all"
t.string "provisioning_label_name"
Expand Down Expand Up @@ -255,6 +254,7 @@
t.string "provision_status", default: "deprovisioned", null: false
t.string "type", default: "Shipit::Stack"
t.boolean "awaiting_provision", default: false, null: false
t.string "path"
t.index ["archived_since"], name: "index_stacks_on_archived_since"
t.index ["awaiting_provision"], name: "index_stacks_on_awaiting_provision"
t.index ["provision_status"], name: "index_stacks_on_provision_status"
Expand Down Expand Up @@ -338,5 +338,4 @@
t.index ["login"], name: "index_users_on_login"
t.index ["updated_at"], name: "index_users_on_updated_at"
end

end
Loading