Add README.md
and {gitea_actions, config}.py
This commit is contained in:
commit
ddf19cd334
19
README.md
Normal file
19
README.md
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
# Gitea Actions
|
||||||
|
|
||||||
|
## Installation:
|
||||||
|
|
||||||
|
Install Gitea Actions Webscraper dependency by running:
|
||||||
|
|
||||||
|
```
|
||||||
|
pip install gitea_actions_webscraper
|
||||||
|
```
|
||||||
|
|
||||||
|
## Configuration:
|
||||||
|
|
||||||
|
Modify `config.py` with the `i_like_gitea` cookie that you can obtain with the `Network` tab (`Ctrl` + `Shift` + `E` with Firefox) when refreshting [the actions webpage](https://gitea.lemnoslife.com/LemnosLife/LemnosLife_Client_chat_majeste/actions).
|
||||||
|
|
||||||
|
## Usage:
|
||||||
|
|
||||||
|
- `./gitea_actions.py check_compilation -m 'Check compilation' -a` which commits, pushes and waits for action execution and returns if compilation successful or the error otherwise
|
||||||
|
- `./gitea_actions.py compile -m 'Compile' -a` which additionally downloads the associated binary
|
||||||
|
- `./gitea_actions.py compile_and_run -m 'Compile and run' -a` which additionally runs the associated binary
|
3
config.py
Normal file
3
config.py
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
instance = 'https://gitea.lemnoslife.com'
|
||||||
|
repository = 'LemnosLife/LemnosLife_Client_chat_majeste'
|
||||||
|
i_like_gitea = 'YOUR_i_like_gitea_COOKIE'
|
67
gitea_actions.py
Executable file
67
gitea_actions.py
Executable file
@ -0,0 +1,67 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
from gitea_actions_webscraper import GiteaActionsWebscraper
|
||||||
|
import config
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import requests
|
||||||
|
import zipfile
|
||||||
|
import io
|
||||||
|
import shlex
|
||||||
|
|
||||||
|
arguments = ' '.join([shlex.quote(argv) for argv in sys.argv[2:]])
|
||||||
|
|
||||||
|
if os.system('git commit ' + arguments) != 0:
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if os.system('git push') != 0:
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
with open('.git/refs/heads/master') as f:
|
||||||
|
lastCommit = f.read()[:-1]
|
||||||
|
|
||||||
|
# Isn't there already live updates on UI?
|
||||||
|
|
||||||
|
gitea_actions_webscraper = GiteaActionsWebscraper(config.instance, config.repository, config.i_like_gitea)
|
||||||
|
while True:
|
||||||
|
while True:
|
||||||
|
actions = gitea_actions_webscraper.getFirstActionsPage()
|
||||||
|
for action in actions:
|
||||||
|
if action.commitHash == lastCommit:
|
||||||
|
break
|
||||||
|
else:
|
||||||
|
print('Waiting to notice action creation')
|
||||||
|
time.sleep(1)
|
||||||
|
continue
|
||||||
|
break
|
||||||
|
if not action.state in ['Running', 'Waiting']:
|
||||||
|
print('Waiting action execution')
|
||||||
|
time.sleep(1)
|
||||||
|
break
|
||||||
|
|
||||||
|
print('Action state:', action.state)
|
||||||
|
if action.state == 'Failure':
|
||||||
|
messages = '\n'.join([stepLog['message'] for stepLog in actions[0].getStepLogs(9)])
|
||||||
|
print(messages)
|
||||||
|
exit(1)
|
||||||
|
|
||||||
|
if not sys.argv[1] in ['compile', 'compile_and_run']:
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
artifactFileName = 'LemnosLife_client_debug'
|
||||||
|
print(f'Downloaing artifact {artifactFileName}')
|
||||||
|
artifactUrl = action.getArtifactUrl(artifactFileName)
|
||||||
|
cookies = {
|
||||||
|
'i_like_gitea': config.i_like_gitea
|
||||||
|
}
|
||||||
|
|
||||||
|
artifactBytes = requests.get(artifactUrl, cookies = cookies).content
|
||||||
|
|
||||||
|
with zipfile.ZipFile(io.BytesIO(artifactBytes)) as z:
|
||||||
|
z.extractall()
|
||||||
|
|
||||||
|
if sys.argv[1] != 'compile_and_run':
|
||||||
|
exit(0)
|
||||||
|
|
||||||
|
os.system(f'./{artifactFileName}')
|
Loading…
Reference in New Issue
Block a user