Change: kubectl and service image
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
name: release-tag
|
name: Build image and deploy
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push
|
push
|
||||||
@@ -6,9 +6,6 @@ on:
|
|||||||
jobs:
|
jobs:
|
||||||
release-image:
|
release-image:
|
||||||
runs-on: imgbuilder
|
runs-on: imgbuilder
|
||||||
# seems broken (2024/06/26)
|
|
||||||
# container:
|
|
||||||
# image: gitea/act_runner
|
|
||||||
env:
|
env:
|
||||||
CONTAINER_REGISTRY: gitea.konchin.com
|
CONTAINER_REGISTRY: gitea.konchin.com
|
||||||
GITEA_TAG: latest
|
GITEA_TAG: latest
|
||||||
@@ -18,6 +15,10 @@ jobs:
|
|||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
- name: Set up Root CA
|
||||||
|
run: |
|
||||||
|
echo "${{ vars.ROOTCA }}" | tee rootca.pem
|
||||||
|
|
||||||
- name: Set up Docker BuildX
|
- name: Set up Docker BuildX
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
@@ -49,5 +50,29 @@ jobs:
|
|||||||
push: true
|
push: true
|
||||||
tags: |
|
tags: |
|
||||||
${{ env.CONTAINER_REGISTRY }}/${{ env.GITEA_REPO }}:${{ env.GITEA_REF_NAME }}
|
${{ env.CONTAINER_REGISTRY }}/${{ env.GITEA_REPO }}:${{ env.GITEA_REF_NAME }}
|
||||||
${{ env.CONTAINER_REGISTRY }}/${{ env.GITEA_REPO }}:${{ env.GITEA_TAG }}
|
${{ env.CONTAINER_REGISTRY }}/${{ env.GITEA_REPO }}:${{ env.GITEA_TAG }}
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
needs: release-image
|
||||||
|
runs-on: imgbuilder
|
||||||
|
container:
|
||||||
|
image: gitea.konchin.com/image/kubectl
|
||||||
|
credentials:
|
||||||
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.REGISTRY_PASSWORD }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Setup kubeconfig
|
||||||
|
run: |
|
||||||
|
echo "${{ secrets.KUBE_CONFIG }}" > .kubeconfig
|
||||||
|
cat .kubeconfig
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
run: |
|
||||||
|
kubectl --kubeconfig .kubeconfig apply -Rf k8s/
|
||||||
|
|
||||||
|
- name: Rollout restart
|
||||||
|
run: |
|
||||||
|
kubectl --kubeconfig .kubeconfig -n rickroll rollout restart deployment algo-dcbot
|
||||||
@@ -5,7 +5,7 @@ import discord, {
|
|||||||
SlashCommandRoleOption,
|
SlashCommandRoleOption,
|
||||||
SlashCommandStringOption,
|
SlashCommandStringOption,
|
||||||
InteractionResponse,
|
InteractionResponse,
|
||||||
Role, APIRole
|
Role, APIRole
|
||||||
} from 'discord.js';
|
} from 'discord.js';
|
||||||
|
|
||||||
import {Command} from '../../classes/command';
|
import {Command} from '../../classes/command';
|
||||||
@@ -14,7 +14,7 @@ import {logger} from '../../logger';
|
|||||||
type CIOR = CommandInteractionOptionResolver;
|
type CIOR = CommandInteractionOptionResolver;
|
||||||
|
|
||||||
function isRole(role: Role | APIRole): role is Role {
|
function isRole(role: Role | APIRole): role is Role {
|
||||||
return role['id'] !== null;
|
return role['id'] !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ApplyRole extends Command{
|
class ApplyRole extends Command{
|
||||||
@@ -29,31 +29,31 @@ class ApplyRole extends Command{
|
|||||||
if(!interaction.guild || !interaction.guild.id || !interaction.guild.name)
|
if(!interaction.guild || !interaction.guild.id || !interaction.guild.name)
|
||||||
throw Error('guild not exist');
|
throw Error('guild not exist');
|
||||||
|
|
||||||
await interaction.reply('Start applying.');
|
await interaction.reply('Start applying.');
|
||||||
let counter: number = 0;
|
let counter: number = 0;
|
||||||
|
|
||||||
const memberList = await interaction.guild.members.fetch();
|
const memberList = await interaction.guild.members.fetch();
|
||||||
logger.debug('fetch done');
|
logger.debug('fetch done');
|
||||||
|
|
||||||
await memberList.each(async member => {
|
await memberList.each(async member => {
|
||||||
if (!role)
|
if (!role)
|
||||||
throw Error('role not exist');
|
throw Error('role not exist');
|
||||||
if (!interaction.guild)
|
if (!interaction.guild)
|
||||||
throw Error('guild not exist');
|
throw Error('guild not exist');
|
||||||
console.log(`${role.id}, ${member}`);
|
console.log(`${role.id}, ${member}`);
|
||||||
|
|
||||||
await interaction.guild.members.addRole({
|
await interaction.guild.members.addRole({
|
||||||
role: role.id,
|
role: role.id,
|
||||||
user: member,
|
user: member,
|
||||||
});
|
});
|
||||||
logger.log(`role ${role} has been added to ${member}.`);
|
logger.log(`role ${role} has been added to ${member}.`);
|
||||||
counter += 1;
|
counter += 1;
|
||||||
if (counter % 10 === 0)
|
if (counter % 10 === 0)
|
||||||
await interaction.editReply(`${counter} applied.`);
|
await interaction.editReply(`${counter} applied.`);
|
||||||
});
|
});
|
||||||
await interaction.editReply(`All ${counter} applied.`);
|
await interaction.editReply(`All ${counter} applied.`);
|
||||||
logger.log(`All ${counter} applied.`);
|
logger.log(`All ${counter} applied.`);
|
||||||
|
|
||||||
}catch(err: unknown){
|
}catch(err: unknown){
|
||||||
let message;
|
let message;
|
||||||
if(err instanceof Error) message = err.message;
|
if(err instanceof Error) message = err.message;
|
||||||
|
|||||||
18
config.ts
18
config.ts
@@ -3,20 +3,20 @@ import dotenv from 'dotenv';
|
|||||||
dotenv.config();
|
dotenv.config();
|
||||||
|
|
||||||
export const config = {
|
export const config = {
|
||||||
// Token and client id can be found in Discord Developer Protol.
|
// Token and client id can be found in Discord Developer Protol.
|
||||||
token: process.env.DC_TOKEN!,
|
token: process.env.DC_TOKEN!,
|
||||||
clientId: process.env.DC_CLIENTID!,
|
clientId: process.env.DC_CLIENTID!,
|
||||||
|
|
||||||
// The user that the bot will DM when starts.
|
// The user that the bot will DM when starts.
|
||||||
adminId: process.env.ADMIN_ID ?? '',
|
adminId: process.env.ADMIN_ID ?? '',
|
||||||
|
|
||||||
nickname: '橘ありす',
|
nickname: '橘ありす',
|
||||||
playing: 'アイドルマスター シンデレラガールズ U149',
|
playing: 'アイドルマスター シンデレラガールズ U149',
|
||||||
logger: {
|
logger: {
|
||||||
logFile: 'test.log',
|
logFile: 'test.log',
|
||||||
},
|
},
|
||||||
|
|
||||||
// The default role id to apply when new member join.
|
// The default role id to apply when new member join.
|
||||||
// Can be obtained in Discord from right clicking the role.
|
// Can be obtained in Discord from right clicking the role.
|
||||||
defaultRole: process.env.DEFAULT_ROLE ?? '',
|
defaultRole: process.env.DEFAULT_ROLE ?? '',
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {logger} from '../logger';
|
|||||||
import {config} from '../config';
|
import {config} from '../config';
|
||||||
|
|
||||||
function isMember(
|
function isMember(
|
||||||
member: GuildMember | PartialGuildMember
|
member: GuildMember | PartialGuildMember
|
||||||
): member is GuildMember {
|
): member is GuildMember {
|
||||||
return member.partial === false;
|
return member.partial === false;
|
||||||
}
|
}
|
||||||
@@ -21,11 +21,11 @@ export async function handleMemberAdd(
|
|||||||
if(!isMember(member))
|
if(!isMember(member))
|
||||||
throw Error('type mismatch: member.partial');
|
throw Error('type mismatch: member.partial');
|
||||||
|
|
||||||
await member.guild.members.addRole({
|
await member.guild.members.addRole({
|
||||||
role: config.defaultRole,
|
role: config.defaultRole,
|
||||||
user: member
|
user: member
|
||||||
});
|
});
|
||||||
logger.log(`${member} has been given role.`);
|
logger.log(`${member} has been given role.`);
|
||||||
}catch(err: unknown){
|
}catch(err: unknown){
|
||||||
let message;
|
let message;
|
||||||
if(err instanceof Error) message = err.message;
|
if(err instanceof Error) message = err.message;
|
||||||
|
|||||||
@@ -11,8 +11,8 @@ export async function loadCommands(client: ExtendedClient): Promise<Array<string
|
|||||||
for(const folder of commandFolders){
|
for(const folder of commandFolders){
|
||||||
const commandsPath = path.join(foldersPath, folder);
|
const commandsPath = path.join(foldersPath, folder);
|
||||||
const commandsFiles = path.basename(__filename).endsWith('.ts')
|
const commandsFiles = path.basename(__filename).endsWith('.ts')
|
||||||
? readdirSync(commandsPath).filter(file => file.endsWith('.ts'))
|
? readdirSync(commandsPath).filter(file => file.endsWith('.ts'))
|
||||||
: readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
: readdirSync(commandsPath).filter(file => file.endsWith('.js'));
|
||||||
for(const file of commandsFiles){
|
for(const file of commandsFiles){
|
||||||
const filePath = path.join(commandsPath, file);
|
const filePath = path.join(commandsPath, file);
|
||||||
const data = await import(filePath);
|
const data = await import(filePath);
|
||||||
|
|||||||
@@ -11,37 +11,34 @@ spec:
|
|||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: algo-dcbot
|
app: algo-dcbot
|
||||||
rel: stable
|
|
||||||
template:
|
template:
|
||||||
metadata:
|
metadata:
|
||||||
labels:
|
labels:
|
||||||
app: algo-dcbot
|
app: algo-dcbot
|
||||||
rel: stable
|
|
||||||
ver: '0.3'
|
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
- name: dcbot
|
- name: dcbot
|
||||||
image: 'gitea.konchin.com/services/algo-dcbot:latest'
|
image: gitea.konchin.com/service/algo-dcbot:latest
|
||||||
env:
|
env:
|
||||||
- name: DC_TOKEN
|
- name: DC_TOKEN
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: algo-dcbot-secret
|
name: algo-dcbot-secret
|
||||||
key: dcbot-token
|
key: DC_TOKEN
|
||||||
- name: DC_CLIENTID
|
- name: DC_CLIENTID
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: algo-dcbot-secret
|
name: algo-dcbot-secret
|
||||||
key: dcbot-id
|
key: DC_CLIENTID
|
||||||
- name: ADMIN_ID
|
- name: ADMIN_ID
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: algo-dcbot-secret
|
name: algo-dcbot-secret
|
||||||
key: maintainer-id
|
key: ADMIN_ID
|
||||||
- name: DEFAULT_ROLE
|
- name: DEFAULT_ROLE
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
name: algo-dcbot-secret
|
name: algo-dcbot-secret
|
||||||
key: default-role-id
|
key: DEFAULT_ROLE
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: regcred
|
- name: regcred
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
---
|
|
||||||
apiVersion: v1
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
name: algo-dcbot-secret
|
|
||||||
namespace: algo-dcbot
|
|
||||||
data:
|
|
||||||
dcbot-id:
|
|
||||||
dcbot-token:
|
|
||||||
default-role-id:
|
|
||||||
maintainer-id:
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
apiVersion: v1
|
|
||||||
kind: Secret
|
|
||||||
metadata:
|
|
||||||
name: regcred
|
|
||||||
namespace: algo-dcbot
|
|
||||||
type: kubernetes.io/dockerconfigjson
|
|
||||||
data:
|
|
||||||
.dockerconfigjson:
|
|
||||||
29
rootca.pem
29
rootca.pem
@@ -1,29 +0,0 @@
|
|||||||
-----BEGIN CERTIFICATE-----
|
|
||||||
MIIFAjCCAuqgAwIBAgIUcrO3uxgk0RfJreCKLOEr/WBS91MwDQYJKoZIhvcNAQEL
|
|
||||||
BQAwGTEXMBUGA1UEAwwOS29uY2hpbi5jb20gQ0EwHhcNMjQwNjIyMTUyNjEyWhcN
|
|
||||||
MzQwNjIwMTUyNjEyWjAZMRcwFQYDVQQDDA5Lb25jaGluLmNvbSBDQTCCAiIwDQYJ
|
|
||||||
KoZIhvcNAQEBBQADggIPADCCAgoCggIBAJvKeaZpfeMG80GKWhyp84yKu72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ULBjzYJf/Rolb5TQWEvDmKguvFvgy
|
|
||||||
zzg9gpp7C9DiDhGVYEJFhOlvFJ/zqyzS1aDKYkinruGvopLj1zna6ZCVn5Gx7e3q
|
|
||||||
Puf4vdPBV0vG9naHQt9mJMfX+gMoedqewCotd9i+PzcFOtARrwWuR05sBhx+AKMr
|
|
||||||
yo4iuO/RPvcGa0V62H6BVQEUec6Yx+vkyCST9MAB48UDs2Bn1nRkZYOriTP16FrX
|
|
||||||
f8iYxZhsz0uKgs3HSVHeNL7rCSuvMCIHuYq5icMfMbqJ/B0+SmvSYeujTwgD6EfW
|
|
||||||
yqhbyvJJWlV12/LTit45XPRtFgEQhzHjYCH+CbatN6BSmSC/eYJnAbI/Oo9TaULy
|
|
||||||
iWZNPqiasRNjCc1Ku0+AQmdjR/ERXQS/JteJivSc0poQT3h0kTEJ4zpdPZ6BFCbb
|
|
||||||
pRQi37EtdB4UdRl7qsK6h0PSR/LyQwwF4K5nWOdSGLzDDLBtxIJEv2yOyy9AbjkW
|
|
||||||
Qtq8sb3dVMp5l8EhsA4rSv0mnX+5jKd5fI0CND53qf2trRuIqrI=
|
|
||||||
-----END CERTIFICATE-----
|
|
||||||
Reference in New Issue
Block a user