dev/action #1

Merged
tom_trgr merged 6 commits from dev/action into main 2025-08-29 15:34:05 +02:00
3 changed files with 86 additions and 33 deletions

View File

@@ -0,0 +1,51 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# GitHub recommends pinning actions to a commit SHA.
# To get a newer version, you will need to update the SHA.
# You can also reference a tag or branch, but the action may change without warning.
name: Publish Docker image
on: push
jobs:
push_to_registry:
name: Push Docker image to Docker Hub
runs-on: ubuntu-latest
# permissions:
# packages: write
# contents: read
# attestations: write
# id-token: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: "check is REGISTRY_TOKEN exists"
env:
super_secret: ${{ secrets.REGISTRY_TOKEN }}
if: ${{ env.super_secret == '' }}
run: 'echo "echo the secret \"REGISTRY_TOKEN\" has not been made; echo please go to \"settings \> secrets \> actions\" to create it"'
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: git.letsstein.de
username: jenkins
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v3
with:
images: git.letsstein.de/tom/anki_convert
- name: Build and push Docker image
id: push
uses: docker/build-push-action@v3
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

View File

@@ -50,10 +50,10 @@ def convert_text(text: str):
for line in seperate(text): for line in seperate(text):
# add anki field into line and count the number of changes # add anki field into line and count the number of changes
line, num = re.subn("(:)(..+)", rf"\1 {{{{c{field_nr}::\2}}}}", line) line, num = re.subn("(:|\.)(..+)", rf"\1 {{{{c{field_nr}::\2}}}}", line)
# if anki field added increase field number # if anki field added increase field number
if num > 0: # if num > 0:
field_nr += 1 # field_nr += 1
# add changed line to array # add changed line to array
changed_lines.append(line) changed_lines.append(line)

View File

@@ -1,8 +1,8 @@
<!DOCTYPE html> <!doctype html>
<html> <html>
<head> <head>
<title>Anki Converter</title> <title>Anki Converter</title>
<link rel="stylesheet" href='/static/style.css' /> <link rel="stylesheet" href="/static/style.css" />
</head> </head>
<body> <body>
<main> <main>
@@ -10,11 +10,11 @@
<h1>Upload File/Enter Text</h1> <h1>Upload File/Enter Text</h1>
<form action="/upload" method="post" enctype="multipart/form-data"> <form action="/upload" method="post" enctype="multipart/form-data">
<label class="custom-file-upload"> <label class="custom-file-upload">
<input id="myfile" type="file" name="file" accept=".pdf"/> <input id="myfile" type="file" name="file" accept=".pdf" />
<span>Custom Upload</span> <span>Custom Upload</span>
</label> </label>
<button type="submit">Upload</button> <button type="submit">Convert</button>
<br> <br />
<textarea name="text">{% if resp_text %}{{ base_text }}{% else %}Text in here{% endif %}</textarea> <textarea name="text">{% if resp_text %}{{ base_text }}{% else %}Text in here{% endif %}</textarea>
</form> </form>
</div> </div>
@@ -22,11 +22,13 @@
<div id="right"> <div id="right">
<h1>Converted Text</h1> <h1>Converted Text</h1>
<button id="copy-btn">Copy Text</button> <button id="copy-btn">Copy Text</button>
<pre id="myInput">{{ resp_text }} <pre id="myInput">
</pre> {{ resp_text }}
</pre
>
</div> </div>
{% endif %} {% endif %}
</main> </main>
<script src="{{url_for('static', filename='script.js')}}"></script> <script src="{{url_for('static', filename='script.js')}}"></script>
</body> </body>
</html> </html>