Skip to content

About

No description, website, or topics provided.

Resources

Stars

33 stars

Watchers

1 watching

Forks

Repository files navigation

GitHub to Confluence Publisher

Publishes Markdown files from a GitHub repository to a Confluence space. On every run it creates new pages, updates existing ones, and deletes stale pages that are no longer in the repo — keeping Confluence always in sync with your repository.

How it works

  • Each folder becomes a Confluence page with a Children Display macro.
  • Each .md file becomes a Confluence page with converted HTML content.
  • Local images are uploaded as page attachments.
  • Every published page is tagged with a Confluence content property so the tool can find and clean up its own pages on the next run.

Prerequisites

  • Docker
  • A Confluence Cloud account (free tier works)
  • A Confluence space and a parent page to publish under

Confluence setup

1. Create a space and a parent page

  1. Log in to your Atlassian site (e.g. https://yoursite.atlassian.net)
  2. Create a new Confluence space — note the space key from the URL: https://yoursite.atlassian.net/wiki/spaces/SPACEKEY/
  3. Create a page inside that space that will be the parent for all published content — note its numeric page ID from the URL: https://yoursite.atlassian.net/wiki/spaces/SPACEKEY/pages/123456/My+Page

2. Create an API token

Go to https://id.atlassian.com/manage-profile/security/api-tokens and create a new token. You will use your email address as the login and this token as the API token.


Configuration

Option A — GitHub Actions (recommended)

No config file needed. Everything is passed via environment variables.

Required secrets (Settings → Secrets and variables → Actions):

Secret Value
confluence_login Your Atlassian account email
confluence_api_token The API token you created

Required variables — set directly in the workflow file or as repository variables:

Variable Example Description
CONFLUENCE_URL https://yoursite.atlassian.net/wiki/rest/api/ REST API base URL
CONFLUENCE_SPACE MYSPACE Space key
CONFLUENCE_PARENT_PAGE_ID 123456 Numeric ID of the parent page

Optional variables:

Variable Default Description
PUBLISHER_PROPERTY_KEY autogenerated-publisher Content property key used to tag published pages
BANNER_REPO_URL https://github.com Link in the auto-generated banner on each page
BANNER_PROJECT_NAME repository name Display name in the banner

Workflow file — copy .github/workflows/publisher.yml into your repo and adjust the env section:

env:
  CONFLUENCE_URL: https://yoursite.atlassian.net/wiki/rest/api/
  CONFLUENCE_SPACE: MYSPACE
  CONFLUENCE_PARENT_PAGE_ID: "123456"
  CONFLUENCE_LOGIN: ${{ secrets.confluence_login }}
  CONFLUENCE_API_TOKEN: ${{ secrets.confluence_api_token }}
  PUBLISHER_MARKDOWN_ROOT: /app/data
  PUBLISHER_IMAGES_ROOT: /app/data_images

Mount your Markdown folder and images folder in the publish step:

-v "${{ github.workspace }}/docs:/app/data:ro" \
-v "${{ github.workspace }}/docs_images:/app/data_images:ro" \

Option B — Local config file

Copy publisher/config/config.yaml and fill in your values:

confluence_url: https://yoursite.atlassian.net/wiki/rest/api/
confluence_space: MYSPACE
confluence_parent_page_id: 123456
publisher_property_key: autogenerated-publisher
banner_repo_url: https://github.com/your-org/your-repo
banner_project_name: My Project
github_folder_with_md_files: ./data
github_folder_with_image_files: ./data_images

Running

With Docker (recommended)

docker build -t confluence-publisher .

docker run --rm \
  -e CONFLUENCE_URL=https://yoursite.atlassian.net/wiki/rest/api/ \
  -e CONFLUENCE_SPACE=MYSPACE \
  -e CONFLUENCE_PARENT_PAGE_ID=123456 \
  -e CONFLUENCE_LOGIN=you@example.com \
  -e CONFLUENCE_API_TOKEN=your-api-token \
  -v ./docs:/app/data:ro \
  -v ./docs_images:/app/data_images:ro \
  confluence-publisher

Dry run (preview without publishing)

docker run --rm \
  -e CONFLUENCE_URL=https://yoursite.atlassian.net/wiki/rest/api/ \
  -e CONFLUENCE_SPACE=MYSPACE \
  -e CONFLUENCE_PARENT_PAGE_ID=123456 \
  -e CONFLUENCE_LOGIN=you@example.com \
  -e CONFLUENCE_API_TOKEN=your-api-token \
  confluence-publisher --dry-run

With a local config file

docker run --rm \
  -e CONFLUENCE_LOGIN=you@example.com \
  -e CONFLUENCE_API_TOKEN=your-api-token \
  -v ./publisher/config/config.yaml:/app/publisher/config/config.yaml:ro \
  -v ./docs:/app/data:ro \
  -v ./docs_images:/app/data_images:ro \
  confluence-publisher

Custom CA certificates (self-hosted Confluence)

If your Confluence instance uses an internal CA, mount the certificate and set REQUESTS_CA_BUNDLE:

-v ./my-ca.crt:/certs/my-ca.crt:ro \
-e REQUESTS_CA_BUNDLE=/certs/my-ca.crt

Content structure

Organise your Markdown files in folders — the directory structure is mirrored in Confluence:

docs/
├── Getting started.md          → page under parent
├── Architecture/               → folder page (Children Display macro)
│   ├── Overview.md             → child page
│   └── Components.md           → child page
└── Operations/
    └── Runbook.md

Images referenced in Markdown are uploaded as attachments to the page:

![diagram](../docs_images/architecture.png)

HTTP/HTTPS image links are left as-is (not uploaded).


Running tests

docker build -t confluence-publisher .

docker run --rm \
  --entrypoint python \
  confluence-publisher \
  -m unittest discover -s /app/publisher -p "test_*.py" -v

Example content

The data_example/ folder contains sample Markdown files demonstrating the supported structure and features. The pipeline in this repository publishes those example files to the demo Confluence space.

About

No description, website, or topics provided.

Resources

Stars

33 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages