Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save strarsis/a761d41980c390ef8330acd9fc109c5c to your computer and use it in GitHub Desktop.
Save strarsis/a761d41980c390ef8330acd9fc109c5c to your computer and use it in GitHub Desktop.
Add wp language files on trellis deploy
---
- block:
- name: Install language files
command: wp core language install {{ item }}
args:
chdir: "{{ deploy_helper.new_release_path }}"
# check for existance of po-file, language install should only run once:
creates: "{{ deploy_helper.new_release_path }}/web/app/languages/{{ item }}.po"
with_items: "{{ project.languages }}"
# not sure if this is the best way to do this, but seems to work:
- name: Get installed language files
find:
paths: "{{ deploy_helper.new_release_path }}/web/app/languages"
patterns: "??.po,???.po,??_*.po"
register: language_files
# this should remove language files if languages are removed from the list:
- name: Uninstall unused language files
command: wp core language uninstall {{ item | splitext | first }}
args:
chdir: "{{ deploy_helper.new_release_path }}"
#debug: msg="{{ item | splitext | first }}"
with_items: "{{ language_files.files | map(attribute='path') | map('basename') | list }}"
when: item | splitext | first not in project.languages
# always run language update:
- name: Install/update language files for core, plugins and themes
command: wp core language update
args:
chdir: "{{ deploy_helper.new_release_path }}"
when: project.languages is defined
...
# add share-after hook:
vars:
deploy_build_before: "{{ playbook_dir }}/deploy-hooks/build-before.yml"
deploy_build_after: "{{ playbook_dir }}/roles/deploy/hooks/build-after.yml"
deploy_share_after: "{{ playbook_dir }}/deploy-hooks/share-after.yml"
deploy_finalize_before: "{{ playbook_dir }}/roles/deploy/hooks/finalize-before.yml"
deploy_finalize_after: "{{ playbook_dir }}/roles/deploy/hooks/finalize-after.yml"
...
wordpress_sites:
example.com:
site_hosts:
- canonical: staging.example.com
# redirects:
# - otherdomain.com
local_path: ../site # path targeting local Bedrock site directory (relative to Ansible root)
repo: [email protected]:example/example.com.git # replace with your Git repo URL
repo_subtree_path: site # relative path to your Bedrock/WP directory in your repo
branch: master
multisite:
enabled: false
ssl:
enabled: false
provider: letsencrypt
cache:
enabled: false
# add languages list, entries must be language codes as used by wp:
languages:
- de_DE
- fr_FR
...
# add languages folder to project_shared_children:
project_shared_children:
- path: web/app/uploads
src: uploads
- path: web/app/languages
src: languages
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment