Compare commits

...

4 Commits

Author SHA1 Message Date
InsanusMokrassar 8983eff109 add default dockerfile 2023-10-05 20:56:38 +06:00
InsanusMokrassar 4c7e4f375a rename nonsudo_deploy 2023-10-05 20:51:35 +06:00
InsanusMokrassar 8f2c98026b add deployment to docker 2023-10-05 20:40:01 +06:00
InsanusMokrassar 132349e1ea update dependencies 2023-10-05 20:29:43 +06:00
6 changed files with 67 additions and 10 deletions

23
.github/workflows/docker-publish.yml vendored Normal file
View File

@ -0,0 +1,23 @@
name: Docker
on:
push:
branches:
- master
jobs:
publishing:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log into registry
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Deploy
run: ./gradlew build && ./nonsudo_deploy

8
Dockerfile Normal file
View File

@ -0,0 +1,8 @@
FROM adoptopenjdk/openjdk11
ADD ./build/distributions/booru_grabber_bot.tar /
RUN chown -R 1000:1000 "/booru_grabber_bot"
USER 1000
ENTRYPOINT ["/booru_grabber_bot/bin/booru_grabber_bot", "/booru_grabber_bot/config.json"]

View File

@ -3,3 +3,5 @@ kotlin.code.style=official
org.gradle.parallel=true
kotlin.js.generate.externals=true
kotlin.incremental=true
version=0.0.3

View File

@ -1,14 +1,14 @@
[versions]
kotlin = "1.8.22"
tgbotapi = "9.1.0"
microutils = "0.19.9"
kotlin = "1.9.10"
tgbotapi = "9.2.1"
microutils = "0.20.6"
imageboard = "2.6.0"
krontab = "2.1.2"
kslog = "1.1.2"
exposed = "0.42.1"
krontab = "2.2.1"
kslog = "1.2.1"
exposed = "0.43.0"
psql = "42.6.0"
clikt = "3.5.2"
clikt = "4.2.1"
[libraries]

24
nonsudo_deploy Executable file
View File

@ -0,0 +1,24 @@
#!/bin/bash
function send_notification() {
echo "$1"
}
function assert_success() {
"${@}"
local status=${?}
if [ ${status} -ne 0 ]; then
send_notification "### Error ${status} at: ${BASH_LINENO[*]} ###"
exit ${status}
fi
}
app=booru_grabber_bot
version="`grep ./gradle.properties -e "^version=" | sed -e "s/version=\(.*\)/\1/"`"
server=insanusmokrassar
assert_success docker build -t $app:"$version" .
assert_success docker tag $app:"$version" $server/$app:$version
assert_success docker tag $app:"$version" $server/$app:latest
assert_success docker push $server/$app:$version
assert_success docker push $server/$app:latest

View File

@ -156,7 +156,7 @@ suspend fun main(args: Array<String>) {
}
onCommand(Regex("(help|start)"), requireOnlyCommandInMessage = true) {
reply(it, EnableArgsParser().getFormattedHelp().takeIf { it.isNotBlank() } ?: return@onCommand)
reply(it, EnableArgsParser().getFormattedHelp() ?.takeIf { it.isNotBlank() } ?: return@onCommand)
}
onCommand("enable", requireOnlyCommandInMessage = false) {
val args = it.content.textSources.drop(1).joinToString("") { it.source }.split(" ")
@ -167,7 +167,7 @@ suspend fun main(args: Array<String>) {
}.onFailure { e ->
e.printStackTrace()
if (it.chat is PrivateChat) {
reply(it, parser.getFormattedHelp())
reply(it, parser.getFormattedHelp()!!)
}
}
runCatchingSafely {
@ -194,7 +194,7 @@ suspend fun main(args: Array<String>) {
}.onFailure { e ->
e.printStackTrace()
if (it.chat is PrivateChat) {
reply(it, parser.getFormattedHelp())
reply(it, parser.getFormattedHelp()!!)
}
}.getOrNull()
}