fix docker compose image, add better error handling for distube and update tagging workflow

This commit is contained in:
Ayden Jahola 2025-09-20 03:06:41 +01:00
parent 07a2f15e6f
commit 7c93017224
3 changed files with 22 additions and 29 deletions

View file

@ -1,10 +1,5 @@
name: Docker
# 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.
on:
push:
branches: ["*"]
@ -12,9 +7,7 @@ on:
# tags: [ 'v*.*.*' ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
jobs:
@ -23,30 +16,21 @@ jobs:
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
# Install the cosign tool except on PR
# https://github.com/sigstore/cosign-installer
- name: Install cosign
if: github.event_name != 'pull_request'
uses: sigstore/cosign-installer@6e04d228eb30da1757ee4e1dd75a0ec73a653e06 #v3.1.1
with:
cosign-release: "v2.1.1"
# Set up BuildKit Docker container builder to be able to build
# multi-platform images and export cache
# https://github.com/docker/setup-buildx-action
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0
# Login against a Docker registry except on PR
# https://github.com/docker/login-action
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0
@ -55,16 +39,19 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# Extract metadata (tags, labels) for Docker
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
# Build and push Docker image with Buildx (don't push on PR)
# https://github.com/docker/build-push-action
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 # v5.0.0

View file

@ -1,7 +1,7 @@
---
services:
bot:
image: ghcr.io/aydenjahola/discord-multipurpose-bot:music
image: ghcr.io/aydenjahola/circuitrix:latest
container_name: discord-bot
restart: unless-stopped
env_file: .env

View file

@ -40,14 +40,20 @@ module.exports = (distube, botName) => {
queue.textChannel.send({ embeds: [embed] });
})
.on("error", (channel, error) => {
console.error("DisTube error:", error);
const embed = createEmbed(
0xff0000,
"❌ Error",
`An error occurred: ${error.message}`
);
if (channel && channel.send) {
channel.send({ embeds: [embed] });
// Check if the 'error' is actually an Error object
if (error instanceof Error) {
console.error("DisTube error:", error);
if (channel && channel.send) {
channel.send("❌ An error occurred: " + error.message.slice(0, 1000));
}
} else {
// Handle cases where 'error' might be something else (like a Queue object)
console.error("Unexpected error parameter received:", typeof error);
console.error("Error content:", error);
if (channel && channel.send) {
channel.send("❌ An unexpected playback error occurred.");
}
}
})
.on("finish", (queue) => {