Repository navigation
Expand file tree
/
Copy pathRakefile
More file actions
83 lines (71 loc) · 3.79 KB
/
Copy pathRakefile
File metadata and controls
83 lines (71 loc) · 3.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
require "json"
require "dotenv/tasks"
VENDOR_DIR = File.join(__dir__, "vendor/ngserver")
RUBY_IMAGES = {
"3.3" => "ruby:3.3-trixie",
"3.4" => "ruby:3.4-trixie",
"4.0" => "ruby:4.0-trixie",
}.freeze
task :push do
ruby = ENV["RUBY_VERSION"]
node = ENV["NODE_VERSION"]
abort "please set RUBY_VERSION" unless ruby
abort "please set NODE_VERSION" unless node
ruby_image = RUBY_IMAGES[ruby] || abort("unsupported RUBY_VERSION #{ruby.inspect} (known: #{RUBY_IMAGES.keys.join(', ')})")
name = "ghcr.io/nerdgeschoss/nerdgeschoss/development-environment:#{ruby}-#{node}"
if Dir.exist?(VENDOR_DIR)
sh "git -C #{VENDOR_DIR} pull --ff-only"
else
sh "git clone --depth 1 git@github.com:nerdgeschoss/servers.git #{VENDOR_DIR}"
end
sh "docker build --pull --push -t #{name} --platform=linux/arm64,linux/amd64 --build-arg RUBY_IMAGE=#{ruby_image} --build-arg NODE_VERSION=#{node} ."
end
Label = Struct.new(:id, :name, :color, :description, :alternative_names)
task update_labels: :dotenv do
repos = ENV["REPOS"]&.split(",")
puts "checking repos: #{repos}"
next unless repos
labels = [
Label.new(name: "backend", color: "34495e", description: "Requires a backend developer.", alternative_names: []),
Label.new(name: "blocked", color: "e74c3c", description: "This issue cannot be worked on currently due to an external dependency.", alternative_names: []),
Label.new(name: "design", color: "3498db", description: "Requires a designer.", alternative_names: []),
Label.new(name: "documentation", color: "c5def5", description: "This issue is about documentation on how the project works.", alternative_names: []),
Label.new(name: "frontend", color: "1abc9c", description: "Requires a frontend developer.", alternative_names: []),
Label.new(name: "needs assistance", color: "fbca04", description: "Assigned person on the issue needs help from another team member.", alternative_names: []),
Label.new(name: "unplanned", color: "f39c12", description: "This task was not planned in a regular sprint and therefore is billed at a higher rate.", alternative_names: []),
Label.new(name: "critical", color: "d35400", description: "This task is critical and has to be executed before other tasks.", alternative_names: []),
Label.new(name: "exploration", color: "eaf296", description: "This task is about exploring future features.", alternative_names: []),
Label.new(name: "support", color: "8e44ad", description: "This task tracks supporting the customer in using the software.", alternative_names: []),
]
repos.each do |repo|
existing = JSON.parse(`gh api repos/#{repo}/labels`).map { Label.new(**_1.slice("id", "name", "color", "description")) }
create = []
delete = []
update = []
existing.each do |label|
new_label = labels.find { _1.name == label.name }
if new_label
update << new_label if new_label.color != label.color || new_label.description != label.description
else
delete << label
end
end
create = labels.select { !existing.map(&:name).include?(_1.name) }
next unless create.any? || delete.any? || update.any?
puts "Repo: #{repo}"
puts "Create: #{create.map(&:name).join(", ")}" if create.any?
puts "Delete: #{delete.map(&:name).join(", ")}" if delete.any?
puts "Update: #{update.map(&:name).join(", ")}" if update.any?
puts "Continue? [y/n]"
next unless STDIN.gets.chomp == "y"
create.each do |label|
sh "gh label create \"#{label.name}\" --color=#{label.color} --description=\"#{label.description}\" --repo=#{repo}"
end
update.each do |label|
sh "gh label edit \"#{label.name}\" --color=#{label.color} --description=\"#{label.description}\" --repo=#{repo}"
end
delete.each do |label|
sh "gh label delete \"#{label.name}\" --repo=#{repo} --yes"
end
end
end