Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

🦊 GitLab Pages preview : the no-compromise hack to serve per-branch pages

Posted on Aug 1 With Gitlab Pages, you can publish static websites directly from a repository in GitLab. By default, we cannot have preview pages : if a job deploys the pages, this overwrites previous content, which disallows preview mode.Some article on the internet show how to get around that with artifacts, knowing that GitLab can display artifacts. But this trick has disadvantages, mainly highly technical links, that have to be shared again after changes on the branch.Some Github gist points into the right direction, but in a complex way and with too few side features.In this article, we will get around the limitation by taking advantage of the cache mechanism, and be able to display per-branch content, with the side benefit of obfuscating the path to ephemeral branches content, if desired.The solution can be broken down to these steps :We assume you already have a way of generating your HTML static content, and just want to serve the files using GitLab Pages.For the code to work, your cache must be centralized, either by using gitlab.com runners, by having a single runner, or by sharing caches between multiple private runners.You need to accept a global cache by deactivating the GiLab option Use separate caches for protected branches in Settings -> CICD -> General Pipelines.The above code has below features :Given the piece of yaml provided, using it in your pipeline, you should be able to share your GitLab Pages on a per-branch basis, on the path you want, while serving the stable content from the root context.For any question or remark, please use below comment section 🤓.If you need information to choose better runner architecture, you can read GitLab Runners topologies : pros and cons.Images generated locally by Automatic1111 using RevAnimated model with PiratePunkAI and Blindbox LoRATemplates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse Scott Nath - May 25 Brendan Falk - Apr 25 Michael Levan - May 24 Alfredo Baldoceda - May 25 Once suspended, zenika will not be able to comment or publish posts until their suspension is removed. Once unsuspended, zenika will be able to comment and publish posts again. Once unpublished, all posts by zenika will become hidden and only accessible to themselves. If zenika is not suspended, they can still re-publish their posts from their dashboard. Note: Once unpublished, this post will become invisible to the public and only accessible to Benoît COUETIL. They can still re-publish the post if they are not suspended. Thanks for keeping DEV Community safe. Here is what you can do to flag zenika: zenika consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy. Unflagging zenika will restore default visibility to their posts. DEV Community — A constructive and inclusive social network for software developers. With you every step of your journey. Built on Forem — the open source software that powers DEV and other inclusive communities.Made with love and Ruby on Rails. DEV Community © 2016 - 2023. We're a place where coders share, stay up-to-date and grow their careers.



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

🦊 GitLab Pages preview : the no-compromise hack to serve per-branch pages

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×