테마를 프로그래매틱으로 설치하기

앱의 app.yml을 통해 테마를 설치하려면 다음 형식을 사용하세요:

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"

YAML 형식 옵션

YAML 파일은 짧은 형식(URL만 포함)과 추가 옵션이 포함된 긴 형식을 지원합니다:

# 짧은 형식 - URL만 포함
theme_name: https://github.com/example/theme.git

# 긴 형식 - 옵션 포함
theme_name:
  url: https://github.com/example/theme_name.git
  branch: "main"
  private_key: ""
  default: false
  add_to_all_themes: false
  skip_update: false
옵션 설명
url (필수) Git 저장소 URL
branch 사용할 Git 브랜치 (기본값은 저장소의 기본 브랜치)
private_key 비공개 저장소를 위한 SSH 비공개 키
default 기본 테마로 설정 (불리언)
add_to_all_themes 컴포넌트 전용 — 모든 테마에 설치 (불리언)
skip_update 테마가 이미 설치된 경우 업데이트 건너뛰기 (불리언)

아카이브에서 설치

로컬 .zip 또는 .tar.gz 아카이브에서 테마를 설치할 수도 있습니다:

THEME_ARCHIVE=/path/to/theme.zip bundle exec rake themes:install:archive

포함된 컴포넌트의 업데이트를 건너뛰려면 UPDATE_COMPONENTS=0을 설정하세요.

12개의 좋아요

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개의 좋아요

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.

6개의 좋아요

(also works with tar.gz)

2개의 좋아요