Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support different Confluence URL patterns #9

Merged
merged 3 commits into from
Dec 17, 2024
Merged
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
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,17 @@ jobs:

Uses basic auth for the rest api.

- `cloud`: The ID can be found by looking at your confluence domain: `https://<cloud>.atlassian.net/...`
- `cloud`: Can be either:
- A subdomain (`acme` for Atlassian hosted instances (e.g. `https://acme.atlassian.net`))
- A full URL (e.g., `https://mycompany.com` for self-hosted instances)

- `user`: The user that generated the access token

- `token`: You can generate the token [here](https://id.atlassian.com/manage-profile/security/api-tokens). Link to [Docs](https://confluence.atlassian.com/cloud/api-tokens-938839638.html)

- `to`: The page ID can be found by simply navigating to the page where you want the content to be postet to and looke at the url. It will look something like this: `https://<cloud-id>.atlassian.net/wiki/spaces/<space>/pages/<page-id>/<title>`
- `to`: The page ID can be found by simply navigating to the page where you want the content to be posted to and look at the url. It will look something like this:
- For Atlassian hosted: `https://<subdomain>.atlassian.net/wiki/spaces/<space>/pages/<page-id>/<title>`
- For self-hosted: `https://<your-url>/wiki/spaces/<space>/pages/<page-id>/<title>`

### Using secrets

Expand Down
8 changes: 7 additions & 1 deletion src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@
with open(join(workspace, envs['from'])) as f:
md = f.read()

url = f"https://{envs['cloud']}.atlassian.net/wiki/rest/api/content/{envs['to']}"
base_url = envs['cloud']
if '://' in base_url: # It's a full URL
# Remove trailing slash if present
base_url = base_url.rstrip('/')
url = f"{base_url}/wiki/rest/api/content/{envs['to']}"
else: # It's a subdomain
url = f"https://{base_url}.atlassian.net/wiki/rest/api/content/{envs['to']}"

current = requests.get(url, auth=(envs['user'], envs['token'])).json()

Expand Down