Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
111 changes: 111 additions & 0 deletions .github/actions/export-from-confluence/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
name: "Export Docs from Confluence"
description: "Exports Confluence pages to local Markdown files, preserving page hierarchy and downloading image attachments"
author: "orangitfi"

inputs:
confluence-url:
description: "Confluence base URL (e.g., https://yourcompany.atlassian.net)"
required: true
confluence-user:
description: "Confluence user email"
required: true
confluence-token:
description: "Confluence API token"
required: true
space-key:
description: "Confluence space key (e.g., DOCS, TECH). Required unless page-id is set."
required: false
default: ""
page-id:
description: "Export a single page by its Confluence page ID (no recursion). Overrides space-key."
required: false
default: ""
root-page-title:
description: "Title of the root page to export (exports its full tree). If omitted, exports the space homepage tree."
required: false
default: ""
output-dir:
description: "Local directory to write exported files"
required: false
default: "exported-docs"
max-depth:
description: "Maximum depth of child pages to export (-1 = unlimited)"
required: false
default: "-1"

runs:
using: "composite"
steps:
- name: Setup Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
with:
python-version: "3.x"

- name: Install uv
shell: bash
run: pip install uv --quiet

- name: Install dependencies
shell: bash
run: uv pip install --system -r ${{ github.action_path }}/requirements.txt

- name: Test Confluence connection
shell: bash
env:
CONFLUENCE_URL: ${{ inputs.confluence-url }}
CONFLUENCE_USER: ${{ inputs.confluence-user }}
CONFLUENCE_API_TOKEN: ${{ inputs.confluence-token }}
CONFLUENCE_SPACE_KEY: ${{ inputs.space-key }}
run: |
python - <<'EOF'
import os
from atlassian import Confluence

conf = Confluence(
url=os.environ['CONFLUENCE_URL'],
username=os.environ['CONFLUENCE_USER'],
password=os.environ['CONFLUENCE_API_TOKEN'],
cloud=True
)

space_key = os.environ.get('CONFLUENCE_SPACE_KEY', '')
if space_key:
try:
space = conf.get_space(space_key)
print(f"✓ Successfully connected to space: {space['name']}")
print(f" Space key: {space['key']}")
print(f" Space URL: {space['_links']['webui']}")
except Exception as e:
print(f"✗ Failed to connect to Confluence space. Check credentials and space key.")
exit(1)
else:
# Page-ID mode — just verify credentials work
try:
conf.get_page_by_id("0")
except Exception:
pass # Expected — just checking auth doesn't throw 401
print("✓ Confluence connection established (page-id mode)")
EOF

- name: Export from Confluence
shell: bash
env:
CONFLUENCE_URL: ${{ inputs.confluence-url }}
CONFLUENCE_USER: ${{ inputs.confluence-user }}
CONFLUENCE_API_TOKEN: ${{ inputs.confluence-token }}
CONFLUENCE_SPACE_KEY: ${{ inputs.space-key }}
ROOT_PAGE_TITLE: ${{ inputs.root-page-title }}
EXPORT_OUTPUT_DIR: ${{ inputs.output-dir }}
run: |
ARGS="--output-dir ${{ inputs.output-dir }} --max-depth ${{ inputs.max-depth }}"
if [ -n "${{ inputs.page-id }}" ]; then
ARGS="$ARGS --page-id ${{ inputs.page-id }}"
fi
if [ -n "${{ inputs.root-page-title }}" ]; then
ARGS="$ARGS --root-page-title \"${{ inputs.root-page-title }}\""
fi
eval python ${{ github.action_path }}/export.py $ARGS

branding:
icon: "download"
color: "blue"
Loading
Loading