1414
1515This is a simple action that can be used to create an MkDocs page and upload it to GitHub Pages.
1616
17- Complete Example (` .github/workflows/mkdocs.yml ` ):
17+ ## Example Usage
18+
19+ ` .github/workflows/mkdocs.yml ` :
1820
1921``` yaml
2022name : MkDocs Build and Deploy
4446 uses : Reloaded-Project/devops-mkdocs@v1
4547 with :
4648 requirements : ./docs/requirements.txt
47- publish-to-pages : true # Default
48- checkout-current-repo : true # Checks out by default.
49+ publish-to-pages : true
50+ checkout-current-repo : true
4951` ` `
5052
5153## Setup
@@ -54,56 +56,91 @@ To use this action in your own repository:
5456
55571. Create a new workflow file (e.g., ` .github/workflows/mkdocs.yml`) in your repository.
56582. Copy the example usage code from above into the new workflow file.
57- 3. If you have additional Python dependencies, create a `requirements.txt` file in your `docs` directory and list them there.
59+ 3. If you have additional Python dependencies, create a `requirements.txt` file in your `docs`
60+ directory and list them there.
5861
5962Ensure your MkDocs configuration file is named `mkdocs.yml` and located in the root of your
60- repository (or update the `CONFIG_FILE ` parameter in the workflow).
63+ repository (or update the `config-file ` parameter in the workflow).
6164
6265# # Configuration
6366
6467# ## Inputs
6568
66- The action supports the following input parameters :
67-
68- - `mkdocs-version` : (Optional) The version of MkDocs to use. Defaults to `latest`. This corresponds to the version in the Python package index.
69- - `requirements` : (Optional) The path to a `requirements.txt` file listing additional Python dependencies. Defaults to `./docs/requirements.txt`.
70- - `config-file` : (Optional) The path to your MkDocs configuration file. Defaults to `mkdocs.yml` in the repository root.
71- - `publish-to-pages` : (Optional) Whether to publish the generated site to GitHub Pages. Defaults to `true`.
72- - `checkout-current-repo` : (Optional) Whether to perform a repository checkout before building the site. Defaults to `true`.
73- - `output-directory` : (Optional) Location of the built MkDocs site. Defaults to `./site`.
74- - `pre-build-command` : (Optional) The path to a pre-build command to run before building the site.
75- - `pre-build-command-shell` : (Optional) The shell to use for running the pre-build command. Defaults to `bash`.
69+ | Input | Required | Default | Description |
70+ | ------------------------- | -------- | ------------------------- | ---------------------------------------------- |
71+ | `mkdocs-version` | No | `latest` | MkDocs version to use |
72+ | `requirements` | No | `./docs/requirements.txt` | Path to the requirements.txt file |
73+ | `config-file` | No | `mkdocs.yml` | Path to the mkdocs.yml file |
74+ | `publish-to-pages` | No | `true` | Whether to publish to GitHub Pages |
75+ | `checkout-current-repo` | No | `true` | Whether to perform repository checkout |
76+ | `output-directory` | No | `./site` | Custom output directory for the MkDocs build |
77+ | `pre-build-command` | No | | Path to the pre-build command |
78+ | `pre-build-command-shell` | No | `bash` | Shell to use for running the pre-build command |
7679
7780# ## Workflow Triggers
7881
7982By default, the example workflow runs on :
8083
81- - Pushes to the `main` branch that modify the `mkdocs.yml` file or files in the `docs/` directory.
82- - Pull requests targeting the `main` branch that modify the `mkdocs.yml` file or files in the `docs/` directory.
84+ - Pushes to the `main` branch that modify the `mkdocs.yml` file or files in the `docs/` directory.
85+ - Pull requests targeting the `main` branch that modify the `mkdocs.yml` file or files in the
86+ ` docs/` directory.
8387- Manual runs triggered via the `workflow_dispatch` event.
8488
8589Modify the `on` section of the workflow as needed for your desired trigger conditions.
8690
91+ # # Examples
92+
93+ Find more examples in [the tests](./.github/workflows/test-mkdocs-workflow.yml).
94+
95+ # ## Custom MkDocs Version
96+
97+ ` ` ` yaml
98+ - name: Deploy MkDocs
99+ uses: Reloaded-Project/devops-mkdocs@v1
100+ with:
101+ mkdocs-version: '9.5.24'
102+ ` ` `
103+
104+ # ## Custom Pre-build Command (Bash)
105+
106+ ` ` ` yaml
107+ - name: Deploy MkDocs
108+ uses: Reloaded-Project/devops-mkdocs@v1
109+ with:
110+ pre-build-command: touch pre-build-bash-executed.txt
111+ pre-build-command-shell: bash
112+ ` ` `
113+
114+ # ## Custom Output Directory
115+
116+ ` ` ` yaml
117+ - name: Deploy MkDocs
118+ uses: Reloaded-Project/devops-mkdocs@v1
119+ with:
120+ output-directory: custom_site_dir
121+ ` ` `
122+
87123# # Viewing the Generated Docs
88124
89- After a successful run, the generated static site will be available on the GitHub Pages site for your repository.
125+ After a successful run, the generated static site will be available on the GitHub Pages site for
126+ your repository.
90127
91128To find the URL :
92129
931301. Navigate to your repository on GitHub.
941312. Go to the "Settings" tab.
951323. Click on "Pages" in the side navigation.
96- 4. The GitHub Pages URL will be listed at the top, in the format `https://<user>.github.io/<repo>/`.
133+ 4. The GitHub Pages URL will be listed at the top, in the format
134+ ` https://<user>.github.io/<repo>/` .
97135
98136# # Why this Exists?
99137
100- The previous actions for MkDocs that I've used always relied on some sort of virtualization,
101- e.g. the use of Docker.
102-
103- Not only was that slow, but sometimes it was not very flexible, for example, the docker
104- image may not have seen the latest version of MkDocs, if it was not well configured.
138+ Previous actions for MkDocs that I've used relied on virtualization, such as Docker. This was slow
139+ and sometimes inflexible, for example, the Docker image may not have the latest version of MkDocs
140+ if not configured properly.
105141
106- This action directly invokes `pip` and `python` on the host machine.
142+ This action directly invokes `pip` and `python` on the host machine for improved performance and
143+ flexibility.
107144
108145# # Contributing
109146
0 commit comments