From 5ae1f78881ebcd0e47fe609e82a0fad6d3518af1 Mon Sep 17 00:00:00 2001 From: Adrian Wannenmacher Date: Thu, 14 Dec 2023 04:47:54 +0100 Subject: [PATCH] mdbook: init --- .github/workflows/mdbook.yml | 53 ++++++++++++++++++++++++++++++++++++ mdbook/Containerfile | 13 +++++++++ mdbook/action.yml | 18 ++++++++++++ 3 files changed, 84 insertions(+) create mode 100644 .github/workflows/mdbook.yml create mode 100644 mdbook/Containerfile create mode 100644 mdbook/action.yml diff --git a/.github/workflows/mdbook.yml b/.github/workflows/mdbook.yml new file mode 100644 index 0000000..b2ba535 --- /dev/null +++ b/.github/workflows/mdbook.yml @@ -0,0 +1,53 @@ +name: Publish mdBook container + +on: + push: + branches: + - "main" + paths: + - "mdbook/**" + - ".github/workflows/mdbook.yml" + +env: + IMAGE: tools-mdbook + VERSION: 0.4.35 + VERSION_MERMAID: 0.12.6 + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Log into Registry + uses: docker/login-action@v2 + with: + registry: ${{ vars.REGISTRY }} + username: ${{ secrets.REGISTRY_USER }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Extract Metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ vars.REGISTRY }}/${{ secrets.REGISTRY_USER }}/${{ env.IMAGE }} + labels: | + org.opencontainers.image.title=mdBook + org.opencontainers.image.description=mdBook in a container + org.opencontainers.image.version=${{ env.VERSION }} + tags: | + type=semver,pattern={{version}},value=v${{ env.VERSION }} + type=semver,pattern={{major}}.{{minor}},value=v${{ env.VERSION }} + type=semver,pattern={{major}}=v${{ env.VERSION }} + + - name: Build and Push + uses: docker/build-push-action@v4 + with: + context: ./mdbook + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + build-args: | + VERSION=${{ env.VERSION }} + VERSION_MERMAID=${{ env.VERSION_MERMAID }} diff --git a/mdbook/Containerfile b/mdbook/Containerfile new file mode 100644 index 0000000..fe35701 --- /dev/null +++ b/mdbook/Containerfile @@ -0,0 +1,13 @@ +FROM rust:slim +LABEL org.opencontainers.image.description="mdBook container (from source)" + +ARG VERSION +ARG VERSION_MERMAID + +RUN cargo install mdbook --version $VERSION +RUN cargo install mdbook-mermaid --version $VERSION_MERMAID + +ENV SOURCE=/book +EXPOSE 3000/tcp + +CMD mdbook serve $SOURCE -n 0.0.0.0 diff --git a/mdbook/action.yml b/mdbook/action.yml new file mode 100644 index 0000000..204a53e --- /dev/null +++ b/mdbook/action.yml @@ -0,0 +1,18 @@ +name: mdBook +description: Build mdBook book +inputs: + source: + description: Where to find the books source. + default: /book + destination: + description: Where to put the rendered content. + default: /rendered +runs: + using: docker + image: docker://git.tfld.dev/tfld/tools-mdbook + args: + - mdbook + - build + - --dest-dir + - ${{ inputs.destination }} + - ${{ inputs.source }}