Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update nomaterial branch #253

Draft
wants to merge 29 commits into
base: nomaterial
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b2ebceb
Added comment about not using the material theme. (#42)
Oct 28, 2020
482a709
Bump example actions/checkout@v2 (#68)
RammusXu Jan 28, 2021
0a362a9
Fix shell check (#69)
RammusXu Jan 29, 2021
5992954
Support multiple package names in `EXTRA_PACKAGES` (#74)
madwort Feb 11, 2021
a7c89aa
fixes build
mhausenblas Feb 25, 2021
e8165b8
Added custom github domain support (#84)
afritzler Mar 5, 2021
0dd60b3
Fixed formatting in readme (#86)
afritzler Mar 8, 2021
485b947
/action.sh: line 42: git: command not found (#88)
Joffref Mar 15, 2021
beffe57
Replace apostrophe with quote (#90)
hiddeco Mar 15, 2021
a8b5e22
Fix multiple $EXTRA_PACKAGES (#109)
madwort Jul 9, 2021
1d39e63
Add lint mode (#120)
cristiklein Sep 9, 2021
2ec5493
Bump actions/checkout from v2.3.3 to v2.3.4 (#44)
dependabot[bot] Nov 4, 2020
48a8883
Bump actions/checkout from 2.3.4 to 2.3.5 (#127)
dependabot[bot] Oct 17, 2021
1b51308
Explain how mkdocs plugins are supported (#130)
rekire Oct 26, 2021
3fd52ec
Bump actions/checkout from 2.3.5 to 2.4.0 (#133)
dependabot[bot] Nov 3, 2021
6a580e6
Bump actions/checkout from 2.4.0 to 3.0.1 (#164)
dependabot[bot] Apr 15, 2022
418b051
Bump actions/checkout from 3.0.1 to 3.0.2 (#165)
dependabot[bot] Apr 22, 2022
f73f101
fix: set workspace as safe directory (#183)
pascaliske Jun 27, 2022
7871702
Lint using the specified CONFIG_FILE (#191)
quad Aug 23, 2022
88006cf
Add note to give write permission to GITHUB_TOKEN (#226)
IoriBranford Feb 12, 2023
29b2c19
Remove forcing strict mode (#199)
dalonsoa Mar 27, 2023
f0a9242
Update Dockerfile (#247)
timlinux Jul 11, 2023
5dda37a
Dockerfile: use python:3.11-alpine3.18
andi34 Jan 17, 2024
d3f852f
Dockerfile: merge RUN lines
andi34 Jan 17, 2024
4c36d1c
README: use nomaterial in example
andi34 Jan 17, 2024
77bd4ca
action: install mkdocs by default
andi34 Jan 17, 2024
7d7e832
README: use actions/checkout@v4 in example
andi34 Jan 17, 2024
737290d
action.sh: allow to change origin
andi34 Aug 29, 2024
e1315f1
README: link to own fork
andi34 Sep 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2.3.3
uses: actions/checkout@v3.0.2

- name: Shellcheck
run: |
Expand Down
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
FROM python:3.8.1-alpine3.11
FROM python:3.11-alpine3.18
LABEL maintainer="Michael Hausenblas, [email protected]"

RUN apk add --no-cache git git-fast-import openssh build-base
WORKDIR /docs

COPY action.sh /action.sh

RUN apk add --no-cache bash && chmod +x /action.sh
RUN apk add --no-cache bash git git-fast-import openssh build-base && chmod +x /action.sh

ENTRYPOINT ["/action.sh"]
27 changes: 24 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GitHub Action to deploy an MkDocs site to GitHub Pages

![GitHub Badge](https://github.com/mhausenblas/mkdocs-deploy-gh-pages/workflows/Build/badge.svg)
![GitHub Badge](https://github.com/andi34/mkdocs-deploy-gh-pages/workflows/Build/badge.svg)

This GitHub action will deploy your [MkDocs site](https://www.mkdocs.org/) as [GitHub Pages](https://pages.github.com/), using the [Material](https://github.com/squidfunk/mkdocs-material) theme. It assumes that an `mkdocs.yml` file is present in the top-level directory and the source files (Markdown, etc.) are in the `docs/` folder. You can use [mhausenblas/mkdocs-template](https://github.com/mhausenblas/mkdocs-template) as a template.

Expand All @@ -20,8 +20,18 @@ This action supports building and deploying with a `GITHUB_TOKEN`. This token is

It is more **secure** than a personal token, since you never actually see the value of the `GITHUB_TOKEN` and also the `GITHUB_TOKEN` is scoped to only work for a **single** repo.

You may need to give the `GITHUB_TOKEN` write permission. Go to your repository's **Settings > Actions > General > Workflow Permissions** and select **Read and write permissions**.

Note that for this approach, Github Pages will be enabled in Settings but you will _not_ have a URL displayed or environment tab yet. So change the Github Pages settings to another target and then back again to `gh-pages` (if that is your branch to serve) - then you will see a URL. This step is only needed on the _first_ deploy and no action is needed later on.

### Alternative `GITHUB_DOMAIN`

In case this action should be used in a Github Enterprise environment you can overwrite the `github.com` domain with your corresponding Github Enterprise domain name by specifying the `GITHUB_DOMAIN` environment variable.

### Custom repository

In case you want to push to another repository than origin define `GITHUB_ORIGIN`. Needs building with `PERSONAL_TOKEN`.

### Custom domain for github pages

MkDocs can be deployed to github pages using a custom domain, if you populate a `CUSTOM_DOMAIN` environment variable. This will generate a CNAME file, which will be placed inside the `/docs` folder.
Expand All @@ -36,6 +46,10 @@ This action supports deployment of mkdocs with different file path , if you popu

Some Python packages require C bindings. These packages can be installed using the `EXTRA_PACKAGES` variable. The `EXTRA_PACKAGES` variable will be passed to the `apk add` command of Alpine Linux before running `pip install` to install the Python packages.

## Installing mkdocs plugins

If you use some mkdocs plugins like [`codeinclude`](https://github.com/rnorth/mkdocs-codeinclude-plugin) then you need to define it as dependency in the typical python way with a `requirements.txt` file. In the sample above you need to add the line `mkdocs-codeinclude-plugin`. Then you need to link the file using the `REQUIREMENTS` variable.

## Example usage

```shell
Expand All @@ -51,13 +65,20 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout main
uses: actions/checkout@v1
uses: actions/checkout@v4
with:
token: ${{ secrets.PAT_TOKEN }} # Uses Personal Access Token (PAT) for checkout, needed to push to another repository

- name: Deploy docs
uses: mhausenblas/mkdocs-deploy-gh-pages@master
uses: andi34/mkdocs-deploy-gh-pages@nomaterial
# Or use andi34/mkdocs-deploy-gh-pages@master to build with the mkdocs-material theme
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# PERSONAL_TOKEN: ${{ secrets.PAT_TOKEN }}
CUSTOM_DOMAIN: optionaldomain.com
CONFIG_FILE: folder/mkdocs.yml
EXTRA_PACKAGES: build-base
# GITHUB_DOMAIN: github.myenterprise.com
# GITHUB_ORIGIN: destination-repository-username/destination-repository-name
REQUIREMENTS: folder/requirements.txt
```
29 changes: 23 additions & 6 deletions action.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,13 @@ function print_info() {
echo -e "\e[36mINFO: ${1}\e[m"
}

if [ -n "${EXTRA_PACKAGES}" ]; then
apk add --no-cache ${EXTRA_PACKAGES}
fi
for package in ${EXTRA_PACKAGES}
do
apk add --no-cache "${package}"
done

# mkdocs is required
pip install mkdocs

if [ -n "${REQUIREMENTS}" ] && [ -f "${GITHUB_WORKSPACE}/${REQUIREMENTS}" ]; then
pip install -r "${GITHUB_WORKSPACE}/${REQUIREMENTS}"
Expand All @@ -31,20 +35,33 @@ else
export CONFIG_FILE="${GITHUB_WORKSPACE}/mkdocs.yml"
fi

if [ -n "${GITHUB_ORIGIN}" ]; then
print_info "setup with GITHUB_ORIGIN"
else
print_info "setup with GITHUB_REPOSITORY"
export GITHUB_ORIGIN=${GITHUB_REPOSITORY}
fi

if [ -n "${GITHUB_TOKEN}" ]; then
print_info "setup with GITHUB_TOKEN"
remote_repo="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
remote_repo="https://x-access-token:${GITHUB_TOKEN}@${GITHUB_DOMAIN:-"github.com"}/${GITHUB_ORIGIN}.git"
elif [ -n "${PERSONAL_TOKEN}" ]; then
print_info "setup with PERSONAL_TOKEN"
remote_repo="https://x-access-token:${PERSONAL_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
remote_repo="https://x-access-token:${PERSONAL_TOKEN}@${GITHUB_DOMAIN:-"github.com"}/${GITHUB_ORIGIN}.git"
else
print_info "no token found; linting"
exec -- mkdocs build --config-file "${CONFIG_FILE}"
fi

# workaround, see https://github.com/actions/checkout/issues/766
git config --global --add safe.directory "$GITHUB_WORKSPACE"

if ! git config --get user.name; then
git config --global user.name "${GITHUB_ACTOR}"
fi

if ! git config --get user.email; then
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.${GITHUB_DOMAIN:-"github.com"}"
fi

git remote rm origin
Expand Down