Skip to content

innofactororg/markdown2confluence

Repository files navigation

markdown2confluence

Convert your Markdown files into Confluence pages with ease using the markdown2confluence script. It uploads all files from a specified Markdown directory to a Confluence space, applying a specific page label and maintaining the folder hierarchy as page structure.

Prerequisites

Before you get started, you will need the space ID of your Confluence space and the ID of the parent page where you want to create new pages.

Configuration

Configure your environment with the following variables before running the script:

  • CONFLUENCE_URL: Your Confluence instance's API endpoint, e.g., https://your-instance.atlassian.net/wiki/rest/api/
  • CONFLUENCE_USERNAME: Your Confluence username
  • CONFLUENCE_PASSWORD: Your Confluence password or API token
  • CONFLUENCE_SPACE_ID: The key of the Confluence space where the pages will be created
  • CONFLUENCE_PARENT_PAGE_ID: The ID of the parent Confluence page under which new pages will be created
  • MARKDOWN_FOLDER: The path to the folder containing markdown files
  • MARKDOWN_SOURCE_REF: The url of the markdown source, e.g. and url to your repo
  • CONFLUENCE_PAGE_LABEL: A label to apply to the Confluence pages to manage them as a group

Optionally, you can also set:

  • CONFLUENCE_PAGE_TITLE_SUFFIX: A suffix to append to the title of Confluence pages, e.g., '(autogenerated)'
  • CONFLUENCE_IGNOREFILE: Path to a file containing patterns to ignore when publishing

Usage

To upload sample markdown files to Confluence, run the following Docker command, replacing VAR1, VAR2, etc., with your Confluence configuration values:

# Run from the root of this repo
docker run --rm \
  -e CONFLUENCE_URL=your_confluence_url \
  -e CONFLUENCE_USERNAME=your_username \
  -e CONFLUENCE_PASSWORD=your_password \
  -e CONFLUENCE_SPACE_ID=your_space_id \
  -e CONFLUENCE_PARENT_PAGE_ID=your_parent_page_id \
  -e MARKDOWN_FOLDER=/data \
  -e MARKDOWN_SOURCE_REF=your_source_ref \
  -e CONFLUENCE_PAGE_TITLE_SUFFIX='(autogenerated)' \
  -e CONFLUENCE_PAGE_LABEL=your_label \
  -e CONFLUENCE_IGNOREFILE=your_ignorefile \
  -v $(pwd)/yourlocalmarkdownfolder:/data \
  --workdir=/data \
  ghcr.io/innofactororg/markdown2confluence:latest

This command will start a Docker container, which uses the provided environment variables to synchronize the contents of your local Markdown folder with your Confluence space, applying the configured page title suffix and label.