update readme with latest state and workings
This commit is contained in:
parent
d39e635d10
commit
7cef7bce11
6 changed files with 32 additions and 12 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,4 +7,3 @@ venv/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
.idea
|
.idea
|
||||||
users.toml
|
users.toml
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
python 3.10.4
|
python 3.10.9
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -1,2 +1,4 @@
|
||||||
web:
|
web:
|
||||||
python -m hug -f src/web.py
|
python -m hug -f src/web.py
|
||||||
|
sync:
|
||||||
|
curl localhost:8000/sync-mattermost
|
||||||
|
|
29
README.md
29
README.md
|
@ -1,5 +1,25 @@
|
||||||
A 'simple' collection of bash scripts that syncs CodiMD files with a certain metadata block to Gitlab
|
A python webserver that automatically hooks into a mattermost instance, listens for any mentions of codiMD files, downloads them locally and then commits them to a git repo based on a specific metadata block in the codimd file.
|
||||||
|
|
||||||
|
**TODO**
|
||||||
|
- Hook into mattermost to automatically react to new files
|
||||||
|
- Change gitlab integration to gitea
|
||||||
|
|
||||||
|
**Done**
|
||||||
|
- Webserver that starts a sync when an endpoint is called
|
||||||
|
- Automatic detection of codimd file links in mattermost message
|
||||||
|
- Download of codimd files
|
||||||
|
- Creation of a gitlab pull request for any new files
|
||||||
|
- Creation of new commits for any new changes to the files. Hereby updating the existing pull request or creating a new one.
|
||||||
|
|
||||||
|
## How to run (currently)
|
||||||
|
|
||||||
|
# Start local webserver
|
||||||
|
make webserver
|
||||||
|
|
||||||
|
# Curl the webserver to trigger the sync
|
||||||
|
make sync
|
||||||
|
|
||||||
|
## CodiMD
|
||||||
|
|
||||||
You need to put the following block somewhere in you CodiMD file.
|
You need to put the following block somewhere in you CodiMD file.
|
||||||
|
|
||||||
|
@ -26,18 +46,13 @@ export CMD_EMAIL=codimd.zeus.gent@mcbloch.dev
|
||||||
export CMD_PASSWORD=*******
|
export CMD_PASSWORD=*******
|
||||||
```
|
```
|
||||||
|
|
||||||
## TODO
|
|
||||||
|
|
||||||
- Add a way to discover new markdown files.
|
|
||||||
- Scraping Mattermost
|
|
||||||
- ? Providing an api endpoint to post an url to ?
|
|
||||||
|
|
||||||
## Used tech
|
## Used tech
|
||||||
|
|
||||||
- [GitLab CLI Tool](https://glab.readthedocs.io/en/latest/index.html)
|
- [GitLab CLI Tool](https://glab.readthedocs.io/en/latest/index.html)
|
||||||
- bash
|
- bash
|
||||||
- git
|
- git
|
||||||
- curl
|
- curl
|
||||||
|
- python
|
||||||
|
|
||||||
### References
|
### References
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import mattermostdriver.exceptions
|
import mattermostdriver.exceptions
|
||||||
|
|
||||||
|
import mattermost_client
|
||||||
from mattermost_client import ChannelApi, MMApi
|
from mattermost_client import ChannelApi, MMApi
|
||||||
|
|
||||||
|
|
||||||
|
@ -11,7 +12,7 @@ def send_message(file_id, file_info, message):
|
||||||
# channel_id = MMApi().get_channel_id("bestuur-dev")
|
# channel_id = MMApi().get_channel_id("bestuur-dev")
|
||||||
channel = ChannelApi(
|
channel = ChannelApi(
|
||||||
channel_id=channel_id,
|
channel_id=channel_id,
|
||||||
user=mattermost.users["flynn"],
|
user=mattermost_client.users["flynn"],
|
||||||
)
|
)
|
||||||
|
|
||||||
prefix = ""
|
prefix = ""
|
||||||
|
|
|
@ -97,7 +97,10 @@ def sync_files_to_gitlab():
|
||||||
if file_info["valid"]:
|
if file_info["valid"]:
|
||||||
local_file_path = file_info["local_file_path"]
|
local_file_path = file_info["local_file_path"]
|
||||||
sync_to = file_info["metadata"]["sync-to"]
|
sync_to = file_info["metadata"]["sync-to"]
|
||||||
sync.sync_file(drive, repo, local_file_path, sync_to)
|
try:
|
||||||
|
sync.sync_file(drive, repo, local_file_path, sync_to)
|
||||||
|
except Exception as e:
|
||||||
|
print("Critical error: Failed to sync file to Gitlab")
|
||||||
|
|
||||||
@hug.get("/sync-mattermost")
|
@hug.get("/sync-mattermost")
|
||||||
def sync_mattermost():
|
def sync_mattermost():
|
||||||
|
|
Loading…
Reference in a new issue