Skip to content

Commit

Permalink
load dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
cupcakearmy committed Dec 8, 2022
1 parent b38b874 commit 93af96c
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
.venv

# Dev
.env
.vscode
Test.md
.github/workflows
*.secrets
.github/workflows/dev.yaml
*.secrets
1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ name = "pypi"
requests = "*"
markdown = "*"
py-gfm = "*"
python-dotenv = "*"

[dev-packages]
autopep8 = "*"
Expand Down
16 changes: 12 additions & 4 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: cupcakearmy/confluence-markdown-sync@v1.0.1
- uses: cupcakearmy/confluence-markdown-sync@v1
with:
from: './README.md'
to: '123456' # The confluence page id where to write the output
Expand All @@ -27,8 +27,10 @@ jobs:
Uses basic auth for the rest api.
- `cloud`: The ID can be found by looking at yout confluence domain: `https://xxx.atlassian.net/...`
- `cloud`: The ID can be found by looking at your confluence domain: `https://<cloud>.atlassian.net/...`

- `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>`
Expand Down
9 changes: 7 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,23 @@
from typing import Dict

import requests
from dotenv import load_dotenv
from markdown import markdown
from mdx_gfm import GithubFlavoredMarkdownExtension

load_dotenv()

workspace = environ.get('GITHUB_WORKSPACE')
if not workspace:
raise Exception('No workspace is set')
print('No workspace is set')
exit(1)

envs: Dict[str, str] = {}
for key in ['from', 'to', 'cloud', 'user', 'token']:
value = environ.get(f'INPUT_{key.upper()}')
if not value:
raise Exception(f'Missing value for {key}')
print(f'Missing value for {key}')
exit(1)
envs[key] = value

with open(join(workspace, envs['from'])) as f:
Expand Down

0 comments on commit 93af96c

Please sign in to comment.