Skip to content

Commit

Permalink
Configure alternatives to GitHub variables while in GitLab
Browse files Browse the repository at this point in the history
  • Loading branch information
unode committed May 15, 2021
1 parent 4eb9729 commit 49ba964
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion _includes/gh_variables.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
{% comment %}
This file was initially used to provide access to GitHub variables
available when rendering websites through GitHub Pages.
It has since then been expanded to also work with GitLab Pages,
although with some limitations due to platform differences.
Particularly, the variable "repo_info" is blank when rendering
through GitLab Pages.

When rendering websites locally, `site.github.url` doesn't get resolved properly
unless a GitHub Personal Access Token is set up and available in the
environment. This leads to warnings and errors when trying to serve the site
Expand All @@ -7,7 +14,7 @@
GitHub where `site.github.url` is defined.
{% endcomment %}

{% if jekyll.environment == "production" %}
{% if jekyll.environment == "production" and site.github %}

{% comment %}
First, get the name of the repository
Expand All @@ -33,6 +40,22 @@
{% assign project_title = site.github.project_title %}
{% assign source_branch = site.github.source.branch %}

{% elsif jekyll.environment == "production" and site.env.GITLAB_CI %}

{% comment %}
This block applies when running in a GitLab CI environment
See https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
for GitLab CI specific variables.
{% endcomment %}

{% assign repo_name = site.env.CI_PROJECT_NAME %}
{% assign repo_info = "" %}
{% assign default_branch = site.env.CI_DEFAULT_BRANCH %}
{% assign repo_url = site.env.CI_REPOSITORY_URL %}
{% assign search_domain_url = site.env.CI_PAGES_URL %}
{% assign project_title = site.env.CI_PROJECT_TITLE %}
{% assign source_branch = site.env.CI_MERGE_REQUEST_SOURCE_BRANCH_NAME %}

{% elsif jekyll.environment == "development" %}

{% assign repo_name = "" %}
Expand Down

0 comments on commit 49ba964

Please sign in to comment.