zcuric
(Zdravko)
21 أبريل 2020، 9:30ص
1
Hi,
do you guys have suggestion how to approach theme deployment in CI/CD fashion? Client expects new theme releases every two weeks and we would like to ship theme in automated process. We are using discourse docker.
We would like to avoid manual installation for each release.
Side note, I don’t know if this is a bug, but the it seems branch doesn’t get saved on first theme installation. (Need to double check this to confirm)
Thanks
إعجابَين (2)
fzngagan
(Faizaan Gagan)
21 أبريل 2020، 9:52ص
2
Its already there. If you install a theme via a git repo, you can update the theme to the latest commit in a single click.
zcuric
(Zdravko)
21 أبريل 2020، 10:09ص
3
I know that, but that’s not the way we want to do it.
We want to have dynamic process without touching the discourse admin. I was thinking using themes command https://github.com/discourse/discourse/blob/master/lib/tasks/themes.rake
docker exec -it app rails themes:install -- # theme data
I don’t know if this command can read files. For example - theme.yaml file which would contain theme info for instalation.
That file could be deployed to shared folder and docker command could read it from there and install the theme or make updates.
david
(David Taylor)
21 أبريل 2020، 10:19ص
4
8 إعجابات
zcuric
(Zdravko)
21 أبريل 2020، 10:24ص
5
@david thanks, but it doesn’t seem clear to me if I can put path to file as an argument. Would this work?
bin/rake themes:install -- theme.yaml
Maybe I could try.
david
(David Taylor)
21 أبريل 2020، 10:29ص
6
I think you would pipe it to STDIN, so something like
cat theme_config.yml | bin/rake themes:install
But I haven’t tested that. Let us know if it works for you
6 إعجابات
zcuric
(Zdravko)
21 أبريل 2020، 11:21ص
7
Your approach works fine. Thanks! Mine doesn’t.
I did experiment a bit with modifying themes.rake
by adding
rake themes:install themeFile="theme.yml"
And this:
task "themes:install" => :environment do |task, args|
if ENV['themeFile']
theme_args = YAML.load_file(ENV['themeFile'])
else
theme_args = (STDIN.tty?) ? '' : STDIN.read
use_json = theme_args == ''
theme_args =
begin
use_json ? JSON.parse(ARGV.last.gsub('--', '')) : YAML::load(theme_args)
rescue
puts use_json ? "Invalid JSON input. \n#{ARGV.last}" : "Invalid YML: \n#{theme_args}"
exit 1
end
end
log, counts = ThemesInstallTask.install(theme_args)
puts log
puts
puts "Results:"
puts " Installed: #{counts[:installed]}"
puts " Updated: #{counts[:updated]}"
puts " Errors: #{counts[:errors]}"
if counts[:errors] > 0
exit 1
end
end
Works fine.
How to run spec for this file?
إعجاب واحد (1)
You should be able to do this:
bin/rake themes:install theme.yml
I added support for passing in JSON, but this code was originally designed to take a yml file as the argument.
إعجابَين (2)
zcuric
(Zdravko)
21 أبريل 2020، 12:30م
9
It throws that it’s not valid json
Invalid JSON input.
theme.yml
My theme.yml
test:
url: "https://github.com/discourse/discourse-faria-theme"
إعجابَين (2)
I believe that should work! I will look into why it is not working anymore.
إعجابَين (2)
Alright, the proper format is bin/rake themes:install < theme.yml
. I will document this better in the code
15 إعجابًا
zcuric
(Zdravko)
21 أبريل 2020، 1:14م
12
Nice! Thanks! Glad I could help a bit
4 إعجابات