Compare commits

..

4 Commits

Author SHA1 Message Date
e3c11d1f58
Merge pull request #9 from elias-AD/support_different_cloud_urls
Support different Confluence URL patterns
2024-12-17 15:00:58 +01:00
elias-AD
e43940725b update readme to make it more clear 2024-11-28 09:34:59 -05:00
elias-AD
a59824adbb 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
2024-11-28 09:29:50 -05:00
elias-AD
090b5472c5 support_cloud_URLs
Instead of relying only on *.atlassian.net, modify the input to be cloudUrl so different flavours of Confluence URLs can be used (including *.jira.com).
2024-11-27 23:19:05 -05:00
2 changed files with 13 additions and 3 deletions

View File

@ -27,13 +27,17 @@ jobs:
Uses basic auth for the rest api. 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 - `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) - `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 ### Using secrets

View File

@ -25,7 +25,13 @@ for key in ['from', 'to', 'cloud', 'user', 'token']:
with open(join(workspace, envs['from'])) as f: with open(join(workspace, envs['from'])) as f:
md = f.read() 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() current = requests.get(url, auth=(envs['user'], envs['token'])).json()