
By Yamuno Team
10 Jun 2026
5 min read
Documentation drift is one of the most common problems in engineering teams. The markdown files in your GitHub repo are accurate — they're updated as part of the same PR that changes the code. The Confluence pages that were supposed to mirror them were last updated six months ago by someone who has since left the team.
This guide shows how to wire GitHub and Confluence together so your repo is the single source of truth and Confluence stays in sync automatically, without anyone manually copying content between the two.
The approach uses the Markdown Importer for Confluence REST API combined with a GitHub Actions workflow. When a push lands on your main branch, the workflow calls the API to import the updated markdown files into the right Confluence pages.
You need:
Store it as a GitHub Actions secret: CONFLUENCE_API_TOKEN. Also store your Confluence email as CONFLUENCE_EMAIL and your Confluence base URL as CONFLUENCE_BASE_URL.
Each import needs a target Confluence page ID — the parent page where the markdown will be created or updated.
To find a page ID:
...confluence/pages/edit-v2/123456789Or use the Confluence REST API:
GET https://your-instance.atlassian.net/wiki/rest/api/content?title=Your+Page+Name&spaceKey=YOURSPACE
Store the page ID as a GitHub Actions variable (CONFLUENCE_PAGE_ID).
Create .github/workflows/sync-docs-to-confluence.yml:
name: Sync Docs to Confluence
on:
push:
branches:
- main
paths:
- 'docs/**'
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Zip docs folder
run: zip -r docs.zip docs/
- name: Import to Confluence
run: |
curl -X POST \
"https://your-instance.atlassian.net/wiki/rest/api/content/${{ vars.CONFLUENCE_PAGE_ID }}/child/page" \
-u "${{ secrets.CONFLUENCE_EMAIL }}:${{ secrets.CONFLUENCE_API_TOKEN }}" \
-H "Content-Type: multipart/form-data" \
-F "[email protected]" \
-F "pageHierarchy=true" \
-F "overwrite=true"
The paths filter means the workflow only triggers when files inside docs/ change — not on every push to main.
The Markdown Importer REST API gives you more control than the UI. The key endpoint for automation:
POST /wiki/rest/atlassian-connect/1/addons/com.yamuno.markdown-importer/resources/api/import
Request body (multipart/form-data):
| Field | Value |
|---|---|
file |
ZIP archive of markdown files |
parentPageId |
Target parent page ID |
spaceKey |
Target Confluence space key |
pageHierarchy |
true to preserve folder structure as page hierarchy |
overwrite |
true to update existing pages instead of creating duplicates |
Authentication: HTTP Basic — email + API token.
A more complete workflow that handles individual files:
#!/bin/bash
# sync-to-confluence.sh
BASE_URL="${CONFLUENCE_BASE_URL}"
EMAIL="${CONFLUENCE_EMAIL}"
TOKEN="${CONFLUENCE_API_TOKEN}"
PAGE_ID="${CONFLUENCE_PAGE_ID}"
SPACE_KEY="${CONFLUENCE_SPACE_KEY}"
# Create ZIP from docs folder
zip -r docs.zip docs/
# Call the import API
curl -s -X POST \
"${BASE_URL}/wiki/rest/atlassian-connect/1/addons/com.yamuno.markdown-importer/resources/api/import" \
-u "${EMAIL}:${TOKEN}" \
-F "[email protected]" \
-F "parentPageId=${PAGE_ID}" \
-F "spaceKey=${SPACE_KEY}" \
-F "pageHierarchy=true" \
-F "overwrite=true" \
| jq '.'
If your docs folder looks like this:
docs/
├── getting-started.md
├── installation.md
├── how-to/
│ ├── first-steps.md
│ └── advanced-usage.md
└── reference/
├── api.md
└── config.md
With pageHierarchy=true, the importer creates a matching Confluence page tree:
Getting Started
Installation
How To
├── First Steps
└── Advanced Usage
Reference
├── API
└── Config
Each folder becomes a parent page. The markdown file names become page titles (with hyphens replaced by spaces and the first letter capitalized).
Markdown Importer reads YAML frontmatter and uses it to set page metadata:
---
title: "API Reference"
---
If a title field is present, the importer uses it as the Confluence page title instead of the filename. This lets you have api.md in the repo but "API Reference" as the Confluence page title.
Other frontmatter fields are ignored for the import but preserved if you export back to markdown.
Push a small change to a doc file on main and watch the Actions tab in GitHub. The workflow should:
push eventCheck Confluence to confirm the pages reflect the changes. The first import creates the pages; subsequent imports update them in place (because overwrite=true).
Sync only changed files: Use git diff --name-only HEAD~1 HEAD -- docs/ in the workflow to identify which files changed, then import just those files instead of the full folder. Faster and avoids unnecessary Confluence page updates.
Multiple doc sources: Run the import step multiple times with different source folders and target page IDs. You can sync docs/public/ to a customer-facing space and docs/internal/ to an internal space in the same workflow.
Preview before merging: Add the sync workflow to pull request branches targeting a staging Confluence space. Reviewers can check how the docs render in Confluence before the PR merges.
Once the workflow is running, your documentation process is:
No manual copying. No drift. The engineers writing the code are the same people keeping the docs current — because it's the same commit.
Featured App
Convert Between Markdown Files and Confluence Pages Effortlessly
Get product updates and tips straight to your inbox.
No spam, ever.
Stop reformatting every PDF export by hand. Here's how to set up reusable PDF templates in Confluence so every export from your team looks the same — with cover pages, branded headers, watermarks, and the right page layout.
Read moreNot all Jira dashboard gadgets are worth the screen space. Here are the widgets and charts that actually help engineering and product teams track what matters.
Read moreQuantitative models are hard enough to build. Documenting them shouldn't be harder. Here's how finance and quant teams use Confluence with LaTeX to document formulas, assumptions, and model logic in a way colleagues can actually understand.
Read more