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).
This commit is contained in:
elias-AD 2024-11-27 23:19:05 -05:00
parent 0d3d395931
commit 090b5472c5
2 changed files with 4 additions and 4 deletions

View File

@ -27,13 +27,13 @@ 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/...` - `cloudUrl`: The URL (without https://) of your confluence instance. E.g: `acme.atlassian.net/...` or `acme.jira.com`
- `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 postet to and looke at the url. It will look something like this: `https://<cloudUrl>/wiki/spaces/<space>/pages/<page-id>/<title>`
### Using secrets ### Using secrets

View File

@ -15,7 +15,7 @@ if not workspace:
exit(1) exit(1)
envs: Dict[str, str] = {} envs: Dict[str, str] = {}
for key in ['from', 'to', 'cloud', 'user', 'token']: for key in ['from', 'to', 'cloudUrl', 'user', 'token']:
value = environ.get(f'INPUT_{key.upper()}') value = environ.get(f'INPUT_{key.upper()}')
if not value: if not value:
print(f'Missing value for {key}') print(f'Missing value for {key}')
@ -25,7 +25,7 @@ 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']}" url = f"https://{envs['cloudUrl']}/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()