Skip to content

Commit

Permalink
add gitlab-specific setup
Browse files Browse the repository at this point in the history
  • Loading branch information
aljazs-flare committed Mar 15, 2024
1 parent 03f0380 commit c432300
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 21 deletions.
4 changes: 4 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# This and ../CODEOWNERS files must match

* @segfaultxavi
.github/workflows @aljazs-flare
.gitlab-ci.yml @aljazs-flare
17 changes: 0 additions & 17 deletions .github/workflows/build-docs.yml

This file was deleted.

5 changes: 3 additions & 2 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
name: deploy-docs

on:
push:
branches:
- main

jobs:
deploy:
if: github.repository == 'flare-foundation/docs'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: 3.x
- run: pip install -r requirements.txt
- run: mkdocs gh-deploy --force
- run: mkdocs build --strict
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
site
.cache/
.cache/
64 changes: 64 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
pages:
needs: []
image: python:3.10-buster
stage: deploy
variables:
GIT_DEPTH: 0
environment:
name: production
url: https://${CI_PROJECT_NAMESPACE}.gitlab.io/-/${CI_PROJECT_NAME}/-/jobs/$CI_JOB_ID/artifacts/public/index.html
action: start
cache:
key:
files:
- requirements.txt
paths:
- .cache
before_script:
- |
# install for sponge
apt-get update 1> /dev/null
apt-get install moreutils -qqy curl 1> /dev/null
# like jq, but for yml - https://github.com/mikefarah/yq
wget --quiet https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq && chmod +x /usr/bin/yq
- if [ -d "public" ]; then echo "Directory ./public exists while it should not as it is used for docs artifacts" && exit 1; fi
- pip install -q -r requirements.txt 1> /dev/null
script:
- |
set -o pipefail
mkdocs build --verbose --strict --site-dir ./public 2>&1 | tee -a /tmp/mkdocs.build.log || { cat /tmp/mkdocs.build.log | grep "WARNING"; exit 1; }
test -f public/index.html && echo "View the generated docs at $CI_ENVIRONMENT_URL"
artifacts:
expire_in: 3 days
paths:
- public
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH

mkdocs-preview:
extends: pages
stage: build
variables:
REPO_NAME: ${CI_PROJECT_PATH}
REPO_URL: ${CI_PROJECT_URL}/-/tree/${CI_COMMIT_REF_NAME}
EDIT_URL: https://gitlab.com/-/ide/project/${CI_PROJECT_PATH}/tree/${CI_COMMIT_REF_NAME}/-/
environment:
name: review/$CI_COMMIT_REF_SLUG
url: https://${CI_PROJECT_NAMESPACE}.gitlab.io/-/${CI_PROJECT_NAME}/-/jobs/$CI_JOB_ID/artifacts/public/index.html
before_script:
- !reference [.mkdocs-base, before_script]
- |
# modify link in navbar according to current git branch (ref)
cat mkdocs.yml | /usr/bin/yq '.repo_url = strenv(REPO_URL)' | sponge mkdocs.yml
cat mkdocs.yml | /usr/bin/yq '.edit_uri = strenv(EDIT_URL)' | sponge mkdocs.yml
cat mkdocs.yml | /usr/bin/yq '.repo_name = strenv(REPO_NAME)' | sponge mkdocs.yml
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
when: never
- if: $CI_MERGE_REQUEST_IID == null
variables:
REPO_NAME: ${CI_PROJECT_PATH}:${CI_COMMIT_REF_NAME}
- if: $CI_MERGE_REQUEST_IID != null
variables:
REPO_NAME: ${CI_PROJECT_PATH}!${CI_MERGE_REQUEST_IID}
REPO_URL: ${CI_PROJECT_URL}/-/merge_requests/${CI_MERGE_REQUEST_IID}
7 changes: 7 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"recommendations": [
"davidanson.vscode-markdownlint",
"gitlab.gitlab-workflow",
"redhat.vscode-yaml"
]
}
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,8 @@
"MD025": false, // We allow both H1 and front matter titles, to have shorter TOCs but full page titles
"MD042": false, // We sometimes use empty links to create buttons
"MD046": false, // Because Admonition indentation looks like an indented code block
}
},
"yaml.customTags": [
"!reference sequence"
]
}
5 changes: 5 additions & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This and .github/CODEOWNERS files must match

* @segfaultxavi
.github/workflows @aljazs-flare
.gitlab-ci.yml @aljazs-flare

0 comments on commit c432300

Please sign in to comment.