Skip to content

Commit

Permalink
Merge pull request #3 from hooopo/repo_full_name_config
Browse files Browse the repository at this point in the history
Add repo_full_name_config
  • Loading branch information
hooopo authored May 5, 2023
2 parents 3c9a7ab + 180bc78 commit cb78927
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 4 deletions.
2 changes: 2 additions & 0 deletions app/models/repo_full_name_config.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
class RepoFullNameConfig < ApplicationRecord
end
7 changes: 7 additions & 0 deletions db/migrate/20230505000021_create_repo_full_name_configs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class CreateRepoFullNameConfigs < ActiveRecord::Migration[7.0]
def change
create_table :repo_full_name_configs do |t|
t.string :full_name, index: {unique: true}
end
end
end
34 changes: 33 additions & 1 deletion db/schema.rb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions lib/sync_github.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
class SyncGithub
def self.run!
raise("REPO_FULL_NAME env missing, please set it") if ENV["REPO_FULL_NAME"].blank?
ENV["REPO_FULL_NAME"].split(",").each do |repo_full_name|
puts "👉 Sync repo #{repo_full_name} info #{ENV['REPO_FULL_NAME']}"
if ENV["REPO_FULL_NAME"].present?
ENV["REPO_FULL_NAME"].split(",").each do |repo_full_name|
RepoFullNameConfig.find_or_create_by(full_name: repo_full_name)
end
end

RepoFullNameConfig.all.each do |config|
repo_full_name = config.full_name
puts "👉 Sync repo #{repo_full_name} of #{ RepoFullNameConfig.all.map{|c| c.full_name }.join(', ') }"
FetchRepo.new(repo_full_name).run

puts "👇 Sync #{repo_full_name} Issues"
Expand Down
11 changes: 11 additions & 0 deletions test/fixtures/repo_full_name_configs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Read about fixtures at https://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

# This model initially had no columns defined. If you add columns to the
# model remove the "{}" from the fixture names and add the columns immediately
# below each fixture, per the syntax in the comments below
#
one: {}
# column: value
#
two: {}
# column: value
7 changes: 7 additions & 0 deletions test/models/repo_full_name_config_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require "test_helper"

class RepoFullNameConfigTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit cb78927

Please sign in to comment.