This repository has been archived by the owner on Dec 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrakefile
112 lines (94 loc) · 2.9 KB
/
rakefile
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
task :build do
Rake::Task[:jekyll].invoke
end
task :update do
Rake::Task[:latest].invoke
Rake::Task[:gallery].invoke
Rake::Task[:bump].invoke
end
desc 'Copy All Files to Live System'
task :deploy do
sh %{ rsync -rcv --exclude-from=.deployignore /var/www/test/ /Users/karlw/sites }
end
desc 'Copy new gallery entries to Live System'
task :deploygallery do
sh %{ rsync -rcv /var/www/test/gallery/ /var/www/html/gallery }
# sh %{ /home/ubuntu/gems/bin/t update "$(cat tools/tweet.txt)" }
end
desc 'Copy new catalog entries to Live System'
task :deploycatalog do
sh %{ rsync -rcv /var/www/test/catalog/ /var/www/html/catalog }
FileUtils.cp( "/var/www/test/api-bin/catalog.txt", "/var/www/html/api-bin/catalog.txt")
filename = '/var/www/html/api-bin/catalog.txt'
line_count = `wc -l "#{filename}"`.strip.split(' ')[0].to_i
require 'net/http'
require 'uri'
require 'json'
uri = URI.parse("https://discord.com/api/webhooks/791096657978327040/DimP_gfybRwEzN1DSWMSE1lb7u-Mwunh3FuTzVjYPS2fVeccPXaIUoFtzA_k1sdyiOas")
#uri = URI.parse("https://discord.com/api/webhooks/775383821029736449/2lzSHGTRpmd-XV-8i6UjvZrwO-b5tDZCIbTQxgoW1XmTGtax-GmHoz0A5OjkDH0NXoHv")
request = Net::HTTP::Post.new(uri)
request.content_type = "application/json"
request.body = JSON.dump({
"content" => "The Visual Catalog has been updated, DrawShield now supports approximately #{line_count} charges."
})
req_options = {
use_ssl: uri.scheme == "https",
}
response = Net::HTTP.start(uri.hostname, uri.port, req_options) do |http|
http.request(request)
end
puts "Reported #{line_count} charges to Discord"
end
desc 'Jekyll Build'
task :jekyll do
sh %{ bundle exec jekyll build -d /Users/karlw/sites }
end
desc 'Commit and Push to git'
task :dogit do
sh %{ git add -A }
sh %{ git commit -m "Gallery Updates" }
sh %{ git push }
end
desc 'Gallery & catalog Build'
task :gallery do
Dir.chdir('tools') do
sh %{ php mkgallery.php }
sh %{ php mkgallery-list.php }
sh %{ stork build --input gallery.toml --output ../source/gallery/gallery.st }
sh %{ php mkcatalog.php }
end
end
desc 'Catalog Images'
task :catalog do
Dir.chdir('tools') do
sh %{ php compile.php }
end
end
desc 'submit Gallery Entries'
task :submit do
# sh %{ git pull }
Dir.chdir('tools') do
sh %{ php publish.php }
end
end
desc 'Set lowest gallery entry'
task :latest do
Dir.chdir('tools') do
sh %{ php latest.php }
end
end
desc 'Run test comparisons'
task :runtests do
Dir.chdir('tests') do
sh %{ ./runtests.sh }
end
end
desc 'Bump build number'
task :bump do
content = File.read('_config.yml')
version_pattern = /buildNum: ([0-9]+)/
current_version = content.match(version_pattern)[1]
next_version = current_version.to_i + 1
File.write('_config.yml', content.gsub(version_pattern, "buildNum: #{next_version}"))
puts "Build number from #{current_version} to #{next_version}!"
end