update readme with latest state and workings

This commit is contained in:
mcbloch 2024-03-26 21:52:18 +01:00
parent d39e635d10
commit 7cef7bce11
6 changed files with 32 additions and 12 deletions

1
.gitignore vendored
View file

@ -7,4 +7,3 @@ venv/
__pycache__/
.idea
users.toml

View file

@ -1 +1 @@
python 3.10.4
python 3.10.9

View file

@ -1,2 +1,4 @@
web:
python -m hug -f src/web.py
sync:
curl localhost:8000/sync-mattermost

View file

@ -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.
@ -26,18 +46,13 @@ export CMD_EMAIL=codimd.zeus.gent@mcbloch.dev
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
- [GitLab CLI Tool](https://glab.readthedocs.io/en/latest/index.html)
- bash
- git
- curl
- python
### References

View file

@ -1,5 +1,6 @@
import mattermostdriver.exceptions
import mattermost_client
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 = ChannelApi(
channel_id=channel_id,
user=mattermost.users["flynn"],
user=mattermost_client.users["flynn"],
)
prefix = ""

View file

@ -97,7 +97,10 @@ def sync_files_to_gitlab():
if file_info["valid"]:
local_file_path = file_info["local_file_path"]
sync_to = file_info["metadata"]["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")
def sync_mattermost():