static-docs: use target from fileserver

The "target_dir" fact is set only for localhost, so can't be
referenced below when running the synchronize on the fileserver.

fileserver.path and static_target should be set globally and can be
referenced in the synchronize step.  Move the master branch check
out and earlier.

Change-Id: Ie9f73df453abb7321950f12b34dcc911b950d630
This commit is contained in:
Ian Wienand 2019-08-27 15:45:06 +10:00
parent 6ddcf28960
commit 91d294ac62

View File

@ -6,6 +6,10 @@
when: "zuul.branch is not defined" when: "zuul.branch is not defined"
fail: fail:
msg: "This playbook must be run in a branch-based pipeline (e.g., 'promote')." msg: "This playbook must be run in a branch-based pipeline (e.g., 'promote')."
- name: Check target branch is master
when: "zuul.branch != 'master'"
fail:
msg: "This job should be only run on the master branch."
- name: Download docs archive - name: Download docs archive
include_role: include_role:
name: download-artifact name: download-artifact
@ -34,14 +38,6 @@
command: "mv {{ item.path }} {{ zuul.executor.work_root }}/docs" command: "mv {{ item.path }} {{ zuul.executor.work_root }}/docs"
with_items: "{{ pdf_files.files }}" with_items: "{{ pdf_files.files }}"
when: pdf_files.matched > 0 when: pdf_files.matched > 0
- name: Set target directory if master
when: "zuul.branch == 'master'"
set_fact:
target_dir: "{{ fileserver.path }}/{{ static_target }}/"
- name: Set target directory if not master
when: "zuul.branch != 'master'"
fail:
msg: "This jobs should be only run on master branch."
- name: Add fileserver - name: Add fileserver
include_role: include_role:
name: add-fileserver name: add-fileserver
@ -52,4 +48,4 @@
- name: Upload docs to static site - name: Upload docs to static site
synchronize: synchronize:
src: "{{ zuul.executor.work_root }}/docs/" src: "{{ zuul.executor.work_root }}/docs/"
dest: "{{ target_dir }}" dest: "{{ fileserver.path }}/{{ static_target }}"