Skip to content

Commit

Permalink
Merge pull request #4 from stakater/templates
Browse files Browse the repository at this point in the history
Add workflow and fix linting
  • Loading branch information
ufateh authored Jan 4, 2024
2 parents 0a13410 + 79cb52b commit a016003
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 18 deletions.
11 changes: 11 additions & 0 deletions .github/md_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"aliveStatusCodes": [429, 200, 520],
"ignorePatterns": [
{
"pattern": "^(https://github.com/stakater-ab/).+"
},
{
"pattern": "^(https://hub-vault).+"
}
]
}
14 changes: 14 additions & 0 deletions .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Pull Request

on:
pull_request:
branches:
- 'main'

jobs:
qa:
uses: stakater/.github/.github/workflows/pull_request_doc_qa.yaml@v0.0.58
with:
MD_CONFIG: .github/md_config.json
DOC_SRC: README.md
MD_LINT_CONFIG: .markdownlint.yaml
24 changes: 24 additions & 0 deletions .github/workflows/push_container.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Push

on:
push:
branches:
- 'main'

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v4
with:
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
fetch-depth: 0 # otherwise, you will fail to push refs to dest repo

- name: Push Latest Tag
uses: anothrNick/github-tag-action@1.61.0
env:
GITHUB_TOKEN: ${{ secrets.STAKATER_GITHUB_TOKEN }}
WITH_V: true
DEFAULT_BUMP: patch
RELEASE_BRANCHES: main
12 changes: 12 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Release

on:
push:
tags:
- "v*"

jobs:
release:
uses: stakater/.github/.github/workflows/release_template.yaml@v0.0.58
secrets:
SLACK_WEBHOOK_URL: ${{ secrets.STAKATER_DELIVERY_SLACK_WEBHOOK }}
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "vocabulary"]
path = vocabulary
url = git@github.com:stakater/vocabulary.git
8 changes: 8 additions & 0 deletions .markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"MD007": { "indent": 4 },
"MD013": false,
"MD024": false,
"MD029": { "style": one },
"MD033": false,
"MD046": false,
}
9 changes: 9 additions & 0 deletions .vale.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
StylesPath = "vocabulary/styles"
MinAlertLevel = warning

Vocab = "Stakater"

# Only check MarkDown files
[*.md]

BasedOnStyles = Vale
56 changes: 38 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,33 @@ This project serves as a shared MkDocs theme for all the Stakater MkDocs project
## Usage Guide

### Pre-requisites

Python 3 environment

### 1. Import as git submodule

Add the submodule to your target Mkdocs project at `theme_common` path. You can learn more about the git submodules [here](https://git-scm.com/book/en/v2/Git-Tools-Submodules).

### 2. Directory structure in target project

Your target project directory should look like this after adding the submodule:
```

```sh
your-project/
theme_common/
...
```

In order to override the `theme_common`, you can mirror this directory in your target project as `theme_override` and customise the files there as you need. Directory structure would look like this after that:
```

```sh
your-project/
theme_common/
theme_override/
```

In your `theme_override` folder, you can replace `mkdocs.yml` with the following starting template:

```yaml
site_name: <project name>
site_url: https://project-name.stakater.com/
Expand All @@ -33,43 +41,55 @@ edit_uri: blob/main/content/

nav:
- index.md

```
### 3. Add content in target MkDocs project
In this project, default mkdocs documentation folder is set to `content`. If you want to override that setting, you can change following properties in `theme_override/mkdocs.yml`:
- `docs_dir`

- `docs_dir`
- `edit_uri`

Add your content and then you can link it in `theme_override/mkdocs.yml` by overriding the following setting:

- `nav`

You can visit MkDocs official documentation to find out how to define `nav` in `mkdocs.yml` file.

Target project's directory structure would look like this after adding `content` dir:
```

```sh
your-project/
theme_common/
theme_override/
content/
```

### 4. Run scripts in target project

Assuming that target project will already have a python environment,
execute the following commands in the root of your target project:

1. Install Python Dependencies:
```bash
pip3 install -r theme_common/requirements.txt
```
2. Combine Theme Resources:
```bash
python theme_common/scripts/combine_theme_resources.py theme_common/resources theme_override/resources dist/_theme
```
> Above command will output combined theme to `dist/_theme`.
3. Produce mkdocs YAML file:
```bash
python theme_common/scripts/combine_mkdocs_config_yaml.py theme_common/mkdocs.yml theme_override/mkdocs.yml mkdocs.yml
```
These scripts will create a combined theme and a `mkdocs.yml` file.

```bash
pip3 install -r theme_common/requirements.txt
```

1. Combine Theme Resources:

```bash
python theme_common/scripts/combine_theme_resources.py theme_common/resources theme_override/resources dist/_theme
```

> Above command will output combined theme to `dist/_theme`.

1. Produce mkdocs YAML file:

```bash
python theme_common/scripts/combine_mkdocs_config_yaml.py theme_common/mkdocs.yml theme_override/mkdocs.yml mkdocs.yml
```

> These scripts will create a combined theme and a `mkdocs.yml` file.

Your target project will now have an mkdocs theme. If you want to customise `mkdocs.yml` or theme resources, you can do so by modifying files in `theme_override` folder and running the above scripts again.
1 change: 1 addition & 0 deletions vocabulary
Submodule vocabulary added at 107a7a

0 comments on commit a016003

Please sign in to comment.