Install a Theme programatically

If you want to install themes via your app.yml, use the following format:

run:
  - exec: echo "Beginning of custom commands"

  - file:
      path: /tmp/mythemes.yml
      contents: |
        discourse-gifs:
          url: https://github.com/discourse/discourse-gifs.git
          add_to_all_themes: true

  - exec:
      cd: $home
      cmd: su discourse -c 'bundle exec rake themes:install < /tmp/mythemes.yml'

  - exec: echo "End of custom commands"
10 Likes

Oh I’m so glad this is possible…I was trying to find a way to load themes across a multisite instance and this may be the easiest way. Thank you!

2 Likes

If anyone else is looking for a programmatical way to import a Theme from the local device with a zip file:

export THEME_ARCHIVE=<abolute-path-to-file> 
bundle exec rake themes:install:archive

or

THEME_ARCHIVE=<abolute-path-to-file> bundle exec rake themes:install:archive

is your friend.

5 Likes

(also works with tar.gz)

2 Likes