Skip to content

Add support for feature branch subdirectory pages

Introduction

#27 is different. Rather than have a sub-domain based on a sub-directory, I want to deploy feature branches into sub-directories, just as described by @inem (with s3) in ci-deployment-and-environments

http://pagesurl/master 
http://pagesurl/branchA 
http://pagesurl/branchB

Proposed .gitlab-ci.yml

pages: 
script: 
- mkdir public 
- mv dist public/$CI_BUILD_REF_NAME 
artifacts: 
paths: 
- public 

The goal is use GitLab pages for feature branch review. I an currently and easily use S3 for this so it is not a bit deal, but I think it would be nice to have the staged review close to my code review.

review: 
stage: deploy 
image: python:2-alpine 
environment: 
name: review/$CI_BUILD_REF_NAME 
url: https://<AMAZON-BUCKET>/$CI_BUILD_REF_NAME/ 
script: 
- pip install awscli 
- aws s3 sync --delete ./dist s3://bucket-name/$CI_BUILD_REF_NAME 
artifacts: 
paths: 
- dist 
  1. Something that S3 can not handle but would be quite nice is if the root directory was browesable and would show the list of directories (deployed feature branches).
  2. Another killer feature would be automatic clean up. In the above example, after a short lived branch is merged and deleted, the staged review is still deployed to my s3 bucket. Pages has some special sauce, removal of the feature branch could remove the stage review. This could be accomplished with scripting so its not a big deal.
  3. I would like to have a redirect rule that I could map the root to one of the branch subfolders: https://gitlaborgname.gitlab.io/projectname -> https://gitlaborgname.gitlab.io/projectname/master

Review in GitLab Pages will be especially sweet when env urls are [more meaningful ] (https://gitlab.com/gitlab-org/gitlab-ce/issues/22749)