Merge pull request 'Clean up CICD and resolve last bugs for release 1' (#6) from workflow into master
Reviewed-on: #6
This commit is contained in:
commit
00e2bd5ee3
3 changed files with 47 additions and 16 deletions
7
.forgejo/runner/Dockerfile
Normal file
7
.forgejo/runner/Dockerfile
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
FROM code.forgejo.org/oci/docker:cli
|
||||||
|
|
||||||
|
# Install Node 24 from Alpine
|
||||||
|
RUN apk add --no-cache nodejs-current npm bash jq curl
|
||||||
|
|
||||||
|
# Verify installations
|
||||||
|
RUN docker --version && node --version && npm --version
|
||||||
|
|
@ -3,14 +3,33 @@ name: Build & Deploy MSTBot
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- master
|
||||||
tags:
|
tags:
|
||||||
- "v*.*.*" # only match version tags like v1.0.0
|
- "v*.*.*" # only match version tags like v1.0.0
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
|
prepare:
|
||||||
|
name: Build & push runner image
|
||||||
|
runs-on: docker-cli-node24
|
||||||
|
steps:
|
||||||
|
- name: Checkout runner Dockerfile
|
||||||
|
uses: actions/checkout@v5
|
||||||
|
with:
|
||||||
|
sparse-checkout: |
|
||||||
|
.forgejo/runner/Dockerfile
|
||||||
|
sparse-checkout-cone-mode: false
|
||||||
|
fetch-depth: 1
|
||||||
|
|
||||||
|
- name: Build & push runner image
|
||||||
|
run: |
|
||||||
|
docker build --network=host -t ${{ vars.REGISTRY_URL }}/minecraftstatus/runner:latest -f .forgejo/runner/Dockerfile .
|
||||||
|
docker push ${{ vars.REGISTRY_URL }}/minecraftstatus/runner:latest
|
||||||
|
|
||||||
build-and-deploy:
|
build-and-deploy:
|
||||||
name: Build, push & deploy
|
name: Build, push & deploy
|
||||||
runs-on: docker-cli-node24
|
runs-on: docker-cli-node24
|
||||||
|
container:
|
||||||
|
image: ${{ vars.REGISTRY_URL }}/minecraftstatus/runner:latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v5
|
uses: actions/checkout@v5
|
||||||
|
|
@ -37,18 +56,24 @@ jobs:
|
||||||
script: |
|
script: |
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
cd /opt/mstbot
|
cd /opt/mstbot
|
||||||
curl -f -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" -o docker-compose.yml "https://git.benrmorgan.com/api/v1/repos/bMorgan/MinecraftStatus/raw/main/docker-compose.yml"
|
curl -f -H "Authorization: token ${{ secrets.FORGEJO_TOKEN }}" -o docker-compose.yml "https://git.benrmorgan.com/api/v1/repos/bMorgan/MinecraftStatus/raw/master/docker-compose.yml"
|
||||||
docker compose down
|
docker compose down
|
||||||
docker compose pull
|
docker compose pull
|
||||||
docker compose up -d
|
docker compose up -d
|
||||||
|
|
||||||
- name: Create Release
|
create-release:
|
||||||
if: startsWith(github.ref, 'refs/tags/')
|
name: Create release
|
||||||
uses: actions/forgejo-release@v2.7.3
|
if: startsWith(github.ref, 'refs/tags/')
|
||||||
|
runs-on: docker-cli-node24
|
||||||
|
container:
|
||||||
|
image: ${{ vars.REGISTRY_URL }}/minecraftstatus/runner:latest
|
||||||
|
steps:
|
||||||
|
- name: Create release
|
||||||
|
uses: actions/forgejo-release@v2.13.4
|
||||||
with:
|
with:
|
||||||
direction: upload
|
direction: upload
|
||||||
title: ${{ github.ref_name }}
|
title: ${{ github.ref_name }}
|
||||||
tag: ${{ github.ref_name }}
|
tag: ${{ github.ref_name }}
|
||||||
token: ${{ secrets.FORGEJO_TOKEN }}
|
token: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
release-dir: .
|
skip-assets: true
|
||||||
release-notes-assistant: true
|
release-notes-assistant: true
|
||||||
|
|
@ -173,8 +173,8 @@ class Other(commands.Cog):
|
||||||
@commands.command(brief="Shows server status", description="Shows server status.")
|
@commands.command(brief="Shows server status", description="Shows server status.")
|
||||||
async def status(self, ctx: discord.ext.commands.context.Context):
|
async def status(self, ctx: discord.ext.commands.context.Context):
|
||||||
with sqlite_conn() as conn:
|
with sqlite_conn() as conn:
|
||||||
ip, port = getMCIP(ctx.guild.id, conn)
|
ip, port, query_port = getMCIP(ctx.guild.id, conn)
|
||||||
mc = JavaServer(ip, port)
|
mc = JavaServer(ip, port, query_port)
|
||||||
|
|
||||||
if mc is None:
|
if mc is None:
|
||||||
await safe_send("There is no server query set up. Run the `setup` command to get started.", ctx=ctx)
|
await safe_send("There is no server query set up. Run the `setup` command to get started.", ctx=ctx)
|
||||||
|
|
@ -193,8 +193,7 @@ class Other(commands.Cog):
|
||||||
@commands.command(brief="Lists online players", description="Lists online players.")
|
@commands.command(brief="Lists online players", description="Lists online players.")
|
||||||
async def players(self, ctx: discord.ext.commands.context.Context):
|
async def players(self, ctx: discord.ext.commands.context.Context):
|
||||||
with sqlite_conn() as conn:
|
with sqlite_conn() as conn:
|
||||||
ip, port = getMCIP(ctx.guild.id, conn)
|
mc = JavaServer(*getMCIP(ctx.guild.id, conn))
|
||||||
mc = JavaServer(ip, port)
|
|
||||||
|
|
||||||
if mc is None:
|
if mc is None:
|
||||||
await safe_send("There is no server query set up. Run the `setup` command to get started.", ctx=ctx)
|
await safe_send("There is no server query set up. Run the `setup` command to get started.", ctx=ctx)
|
||||||
|
|
@ -211,8 +210,8 @@ class Other(commands.Cog):
|
||||||
@commands.command(brief="Shows last query time", description="Shows last query time. Useful for debugging server connection issues.")
|
@commands.command(brief="Shows last query time", description="Shows last query time. Useful for debugging server connection issues.")
|
||||||
async def lastquery(self, ctx: discord.ext.commands.context.Context):
|
async def lastquery(self, ctx: discord.ext.commands.context.Context):
|
||||||
with sqlite_conn() as conn:
|
with sqlite_conn() as conn:
|
||||||
ip, port = getMCIP(ctx.guild.id, conn)
|
ip, port, query_port = getMCIP(ctx.guild.id, conn)
|
||||||
mc = JavaServer(ip, port)
|
mc = JavaServer(ip, port, query_port)
|
||||||
last = getMCQueryTime(ctx.guild.id, conn)
|
last = getMCQueryTime(ctx.guild.id, conn)
|
||||||
|
|
||||||
if mc is None:
|
if mc is None:
|
||||||
|
|
@ -237,7 +236,7 @@ async def setAnn(ctx: discord.ext.commands.context.Context, ann: bool, cid: Unio
|
||||||
return
|
return
|
||||||
|
|
||||||
with sqlite_conn() as conn:
|
with sqlite_conn() as conn:
|
||||||
ip, _ = getMCIP(ctx.guild.id, conn)
|
ip, _, _ = getMCIP(ctx.guild.id, conn)
|
||||||
|
|
||||||
conn.execute("""
|
conn.execute("""
|
||||||
UPDATE servers
|
UPDATE servers
|
||||||
|
|
@ -259,7 +258,7 @@ async def setAnn(ctx: discord.ext.commands.context.Context, ann: bool, cid: Unio
|
||||||
|
|
||||||
async def setShowHours(ctx: discord.ext.commands.context.Context, show_hours: bool):
|
async def setShowHours(ctx: discord.ext.commands.context.Context, show_hours: bool):
|
||||||
with sqlite_conn() as conn:
|
with sqlite_conn() as conn:
|
||||||
ip, _ = getMCIP(ctx.guild.id, conn)
|
ip, _, _ = getMCIP(ctx.guild.id, conn)
|
||||||
|
|
||||||
conn.execute("""
|
conn.execute("""
|
||||||
UPDATE servers
|
UPDATE servers
|
||||||
|
|
@ -484,8 +483,8 @@ async def do_bot_cleanup(sid: int, ctx: Union[discord.ext.commands.context.Conte
|
||||||
print(currServ.name, "Error: I don't have permission to delete channels.")
|
print(currServ.name, "Error: I don't have permission to delete channels.")
|
||||||
|
|
||||||
with sqlite_conn() as conn:
|
with sqlite_conn() as conn:
|
||||||
ip, port = getMCIP(sid, conn)
|
ip, port, query_port = getMCIP(sid, conn)
|
||||||
mc = JavaServer(ip, port)
|
mc = JavaServer(ip, port, query_port)
|
||||||
|
|
||||||
conn.execute("DELETE FROM servers WHERE id = ?", (sid,))
|
conn.execute("DELETE FROM servers WHERE id = ?", (sid,))
|
||||||
conn.execute("DELETE FROM names WHERE id = ?", (sid,))
|
conn.execute("DELETE FROM names WHERE id = ?", (sid,))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue