Skip to content

Commit a59824a

Browse files
committed
modified cloud to support both subdomains (*.atlassian.net) or actual domains (e.g. ame.jira.com)
instead of introducing a potential breaking change, this will support both cases
1 parent 090b547 commit a59824a

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
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-
- `cloudUrl`: The URL (without https://) of your confluence instance. E.g: `acme.atlassian.net/...` or `acme.jira.com`
30+
- `cloud`: Can be either:
31+
- A subdomain (e.g., `acme` for Atlassian hosted instances)
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://<cloudUrl>/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: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
exit(1)
1616

1717
envs: Dict[str, str] = {}
18-
for key in ['from', 'to', 'cloudUrl', 'user', 'token']:
18+
for key in ['from', 'to', 'cloud', 'user', 'token']:
1919
value = environ.get(f'INPUT_{key.upper()}')
2020
if not value:
2121
print(f'Missing value for {key}')
@@ -25,7 +25,13 @@
2525
with open(join(workspace, envs['from'])) as f:
2626
md = f.read()
2727

28-
url = f"https://{envs['cloudUrl']}/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)