Ansiblify prepare-infra-docs-for-afs

The existing code in branch made a directory for build/{{ branch.tag |
dirname }} but then moved things to build/{{ branch.tag | basename }}
which produced:

  html/
  html/feature
  html/zuulv3

Fix that. While we're in there, go ahead and change this into individual
ansible tasks.

Change-Id: Ib757d1f8bf76012d2d436565913e750c4a5d52a7
This commit is contained in:
Monty Taylor 2017-09-06 13:39:08 -05:00
parent 294d778ce8
commit 2d2a717f29
No known key found for this signature in database
GPG Key ID: 7BAE94BC7141A594
4 changed files with 46 additions and 50 deletions

View File

@ -1,12 +1,14 @@
- name: Process other branch changes
args:
chdir: "{{ zuul_work_dir }}"
# Put other branch changes in dir named after branch under the
# build dir. When Zuul copies these files they will be
# accessible under the developer docs root using the branch name.
# EG: feature/foo or milestone-proposed
shell: |
mv doc/build/html doc/build/tmp
mkdir -p doc/build/html/{{ zuul.branch | dirname }}
mv doc/build/tmp doc/build/html/{{ zuul.branch | basename }}
tags: skip_ansible_lint
# Put other branch changes in dir named after branch under the
# build dir. When Zuul copies these files they will be
# accessible under the developer docs root using the branch name.
# EG: feature/foo or milestone-proposed
- name: Move built html to the side
command: "mv {{ doc_build_dir }}/html {{ doc_build_dir }}/tmp"
- name: Ensure destination path exists
file:
path: "{{ doc_build_dir }}/html/{{ zuul.branch | dirname }}"
state: directory
- name: Move html to branch location
command: "mv {{ doc_build_dir }}/tmp {{ doc_build_dir }}/html/{{ zuul.branch }}"

View File

@ -1,6 +1,10 @@
- name: Set build dir fact
set_fact:
doc_build_dir: "{{ zuul_work_dir }}/doc/build"
- name: Write marker text
copy:
dest: "{{ zuul_work_dir }}/doc/build/html/.root-marker"
dest: "{{ doc_build_dir }}/html/.root-marker"
content: "Project: {{ zuul.project.name }} Branch: {{ zuul.branch }} Build: {{ zuul.build }} Revision: {{ zuul.ref }}"
- name: Process tagged build

View File

@ -1,12 +1,15 @@
- name: Process stable branch changes
args:
chdir: "{{ zuul_work_dir }}"
# Put stable release changes in dir named after stable release under the
# build dir. When Zuul copies these files they will be accessible under
# the developer docs root using the stable release name.
shell: |
# Move the docs into a subdir if this is a stable branch build
mv doc/build/html doc/build/tmp
mkdir doc/build/html
mv doc/build/tmp doc/build/html/{{ zuul.branch | replace('stable/', '') }}
tags: skip_ansible_lint
# Put stable release changes in dir named after stable release under the
# build dir. When Zuul copies these files they will be accessible under
# the developer docs root using the stable release name.
- name: Move built html to the side
command: "mv {{ doc_build_dir }}/html {{ doc_build_dir }}/tmp"
- name: Ensure destination path exists
file:
path: "{{ doc_build_dir }}/html"
state: directory
- name: Move html to branch location without stable prefix
command: >-
mv {{ doc_build_dir }}/tmp
{{ doc_build_dir }}/html/{{ zuul.branch | replace('stable/', '') }}

View File

@ -1,31 +1,18 @@
- name: Get latest tag for project
args:
chdir: "{{ zuul_work_dir }}"
executable: /bin/bash
# This is a hack to ignore the year.release tags in projects since
# now all projects use semver based versions instead of date based
# versions. The date versions will sort higher even though they
# should not so we just special case it here.
shell: |
git tag | sed -n -e '/^20[0-9]\{2\}\..*$/d' -e '/^[0-9]\+\(\.[0-9]\+\)*$/p' | sort -V | tail -1
register: latest
tags: skip_ansible_lint
# Put tagged releases in proper location. All tagged builds get copied to
# BUILD_DIR/tagname. If this is the latest tagged release the copy of files
# at BUILD_DIR remains. When Zuul copies this file the root developer
# docs are always the latest release with older tags available under the
# root in the tagname dir.
- name: Copy content to the temporary location
copy:
remote_src: true
src: "{{ doc_build_dir }}/html"
dest: "{{ doc_build_dir }}/tmp"
- name: Process tags only builds when the tag is the latest tag
args:
chdir: "{{ zuul_work_dir }}"
# Now publish to / and /$TAG if this is the latest version for projects
# and we are only publishing from the release pipeline,
# or just /$TAG otherwise.
shell: |
# Copy the docs into a subdir if this is a tagged build
mkdir doc/build/{{ zuul.tag }}
cp -R doc/build/html/. doc/build/{{ zuul.tag }}
mv doc/build/{{ zuul.tag }} doc/build/html/{{ zuul.tag }}
tags: skip_ansible_lint
- name: Make destination path
file:
path: "{{ doc_build_dir }}/html/{{ zuul.tag | dirname }}"
state: directory
- name: Move html to branch location
command: "mv {{ doc_build_dir }}/tmp {{ doc_build_dir }}/html/{{ zuul.tag }}"