fix: 🔀 Fix merge
All checks were successful
Publish staging Docker image / Push Docker image to Gitea Container Registry (push) Successful in 1m41s
All checks were successful
Publish staging Docker image / Push Docker image to Gitea Container Registry (push) Successful in 1m41s
This commit is contained in:
commit
437b6431d0
50
.github/workflows/push-docker-stable.yml
vendored
Normal file
50
.github/workflows/push-docker-stable.yml
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# 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 staging Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
push_to_registry:
|
||||||
|
name: Push Docker image to Gitea Container Registry
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out the repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Install Docker
|
||||||
|
run: curl -fsSL https://get.docker.com | sh
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
||||||
|
with:
|
||||||
|
registry: gitea.louisgallet.fr
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
-
|
||||||
|
# Add support for more platforms with QEMU (optional)
|
||||||
|
# https://github.com/docker/setup-qemu-action
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: "linux/amd64,linux/arm64"
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: gitea.louisgallet.fr/lgallet/bot-louis:latest
|
||||||
|
labels: VERSION=stable
|
50
.github/workflows/push-docker-staging.yml
vendored
Normal file
50
.github/workflows/push-docker-staging.yml
vendored
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
# 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 staging Docker image
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- feature/*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
push_to_registry:
|
||||||
|
name: Push Docker image to Gitea Container Registry
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out the repo
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: Install Docker
|
||||||
|
run: curl -fsSL https://get.docker.com | sh
|
||||||
|
- name: Log in to Docker Hub
|
||||||
|
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
|
||||||
|
with:
|
||||||
|
registry: gitea.louisgallet.fr
|
||||||
|
username: ${{ secrets.DOCKER_USERNAME }}
|
||||||
|
password: ${{ secrets.DOCKER_PASSWORD }}
|
||||||
|
|
||||||
|
-
|
||||||
|
# Add support for more platforms with QEMU (optional)
|
||||||
|
# https://github.com/docker/setup-qemu-action
|
||||||
|
name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
-
|
||||||
|
name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Build and push Docker image
|
||||||
|
uses: docker/build-push-action@v2
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
platforms: "linux/amd64,linux/arm64"
|
||||||
|
file: ./Dockerfile
|
||||||
|
push: true
|
||||||
|
tags: gitea.louisgallet.fr/lgallet/bot-louis:staging
|
||||||
|
labels: VERSION=staging
|
@ -25,40 +25,46 @@ module.exports = {
|
|||||||
|
|
||||||
const row = new ActionRowBuilder()
|
const row = new ActionRowBuilder()
|
||||||
.addComponents(cancel, confirm);
|
.addComponents(cancel, confirm);
|
||||||
|
|
||||||
const response = await interaction.reply({
|
const response = await interaction.reply({
|
||||||
content: 'Are you sure you want to start the Minecraft server?',
|
content: 'Are you sure you want to start the Minecraft server?',
|
||||||
components: [row],
|
components: [row]
|
||||||
});
|
})
|
||||||
|
// Before stop variable which return the time between now and 4am in discord timestamp
|
||||||
|
const date = new Date(new Date().setDate(new Date().getDate() + 1))
|
||||||
|
date.setUTCHours(3, 0, 0, 0)
|
||||||
|
const test = Math.round(date.getTime() / 1000);
|
||||||
const collectorFilter = i => i.user.id === interaction.user.id;
|
const collectorFilter = i => i.user.id === interaction.user.id;
|
||||||
|
let allowed = false;
|
||||||
|
for (const role of config.allowedRoles) {
|
||||||
|
if (interaction.member.roles.cache.has(role)) {
|
||||||
|
allowed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
const confirmation = await response.awaitMessageComponent({ filter: collectorFilter, time: 30_000 });
|
const confirmation = await response.awaitMessageComponent({ filter: collectorFilter, time: 30_000 });
|
||||||
if (confirmation.customId === 'confirm') {
|
if (confirmation.customId === 'confirm') {
|
||||||
// eslint-disable-next-line no-undef
|
if (!allowed) {
|
||||||
proxmox.qemu.start('pve', '102', function(err) {
|
await confirmation.update({ content: 'You do not have permission to start the Minecraft server.', components: [] });
|
||||||
if (err) {
|
return;
|
||||||
confirmation.update('Error starting the Minecraft server: ' + err);
|
|
||||||
}
|
}
|
||||||
else {
|
proxmox.qemu.start("pve", "103", function(err) {
|
||||||
|
if (err) {
|
||||||
|
confirmation.update("Error starting the Minecraft server: " + err);
|
||||||
|
} else {
|
||||||
const linkButton = new ButtonBuilder()
|
const linkButton = new ButtonBuilder()
|
||||||
.setStyle(ButtonStyle.Link)
|
.setStyle(ButtonStyle.Link)
|
||||||
.setLabel('Web Interface')
|
.setLabel('Web Interface')
|
||||||
.setURL('https://mc.louisgallet.fr');
|
.setURL('https://mc.louisgallet.fr')
|
||||||
const linkRow = new ActionRowBuilder()
|
const row = new ActionRowBuilder()
|
||||||
.addComponents(linkButton);
|
.addComponents(linkButton)
|
||||||
confirmation.update({ content: 'Minecraft server started successfully. Please wait a few minutes for it to boot.', components: [linkRow] });
|
confirmation.update({content: "Minecraft server started successfully. Please wait a few minutes for it to boot. Use the command `/stop-mc` to stop it, otherwise, the server will be automatically shut down " + `<t:${test}:R>`, components: [row]});
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
} else if (confirmation.customId === 'cancel') {
|
||||||
else if (confirmation.customId === 'cancel') {
|
|
||||||
await confirmation.update({ content: 'Minecraft server start cancelled.', components: [] });
|
await confirmation.update({ content: 'Minecraft server start cancelled.', components: [] });
|
||||||
}
|
}
|
||||||
}
|
} catch (e) {
|
||||||
catch (e) {
|
|
||||||
// eslint-disable-next-line no-undef
|
|
||||||
await confirmation.update({ content: 'You took too long to respond.', components: [] });
|
await confirmation.update({ content: 'You took too long to respond.', components: [] });
|
||||||
}
|
}
|
||||||
|
}
|
||||||
},
|
}
|
||||||
};
|
|
@ -12,13 +12,12 @@ module.exports = {
|
|||||||
.setName('stop-mc')
|
.setName('stop-mc')
|
||||||
.setDescription('Stops the minecraft server machine.'),
|
.setDescription('Stops the minecraft server machine.'),
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
proxmox.qemu.shutdown('pve', '102', function(err) {
|
proxmox.qemu.shutdown("pve", "103", function(err, res) {
|
||||||
if (err) {
|
if (err) {
|
||||||
interaction.reply('Error starting the Minecraft server: ' + err);
|
interaction.reply("Error starting the Minecraft server: " + err);
|
||||||
|
} else {
|
||||||
|
interaction.reply("Minecraft server stopped successfully.");
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
interaction.reply('Minecraft server stopped successfully.');
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
17
commands/utility/check-perms.js
Normal file
17
commands/utility/check-perms.js
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
const { SlashCommandBuilder } = require('discord.js')
|
||||||
|
const config = require('../../config.json')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('check-perms')
|
||||||
|
.setDescription('Check if the user has the correct permissions to start the Minecraft server.'),
|
||||||
|
async execute(interaction) {
|
||||||
|
for (const role of config.allowedRoles) {
|
||||||
|
if (interaction.member.roles.cache.has(role)) {
|
||||||
|
await interaction.reply({ content: 'You have the correct permissions to start the Minecraft server.', ephemeral: true });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await interaction.reply({ content: 'You have the correct permissions to start the Minecraft server.', ephemeral: true });
|
||||||
|
},
|
||||||
|
}
|
13
commands/utility/test-time.js
Normal file
13
commands/utility/test-time.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const { SlashCommandBuilder } = require('discord.js')
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
data: new SlashCommandBuilder()
|
||||||
|
.setName('test-time')
|
||||||
|
.setDescription('Test the time between now and 4am in discord timestamp'),
|
||||||
|
async execute(interaction) {
|
||||||
|
const date = new Date(new Date().setDate(new Date().getDate() + 1))
|
||||||
|
date.setUTCHours(3, 0, 0, 0)
|
||||||
|
const test = Math.round(date.getTime() / 1000);
|
||||||
|
await interaction.reply({ content: `Time between now and 4am: <t:${test}:R>`}, {ephemeral: true});
|
||||||
|
},
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user