Skip to content

Commit e3c11d1

Browse files
authored
Merge pull request #9 from elias-AD/support_different_cloud_urls
Support different Confluence URL patterns
2 parents 0d3d395 + e439407 commit e3c11d1

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

README.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,17 @@ jobs:
2727
2828
Uses basic auth for the rest api.
2929
30-
- `cloud`: The ID can be found by looking at your confluence domain: `https://<cloud>.atlassian.net/...`
30+
- `cloud`: Can be either:
31+
- A subdomain (`acme` for Atlassian hosted instances (e.g. `https://acme.atlassian.net`))
32+
- A full URL (e.g., `https://mycompany.com` for self-hosted instances)
3133

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

3436
- `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)
3537

36-
- `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>`
38+
- `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:
39+
- For Atlassian hosted: `https://<subdomain>.atlassian.net/wiki/spaces/<space>/pages/<page-id>/<title>`
40+
- For self-hosted: `https://<your-url>/wiki/spaces/<space>/pages/<page-id>/<title>`
3741

3842
### Using secrets
3943

src/main.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@
2525
with open(join(workspace, envs['from'])) as f:
2626
md = f.read()
2727

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

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

0 commit comments

Comments
 (0)