Compare commits

...

2 Commits

Author SHA1 Message Date
bc9fe79efc update discord to roblox api 2022-11-15 22:12:58 -05:00
9f657f9bd0 Update CI to new infra
All checks were successful
continuous-integration/drone/push Build is passing
2022-11-15 21:57:35 -05:00
10 changed files with 49 additions and 347 deletions

View File

@ -1,55 +0,0 @@
---
kind: pipeline
type: docker
platform:
os: linux
arch: amd64
steps:
- name: build
image: gcr.io/kaniko-project/executor:latest
entrypoint: [ /kaniko/executor ]
command: [ "--context=/drone/src", "--dockerfile=Dockerfile", "--destination=image", "--no-push", "--tarPath=maptest-bot.tar" ]
- name: scan-image
image: aquasec/trivy:latest
commands:
- trivy image --exit-code 1 --severity CRITICAL --input maptest-bot.tar
- name: push-image
image: alpine:3
commands:
- wget -qO- https://github.com/google/go-containerregistry/releases/download/v0.9.0/go-containerregistry_Linux_x86_64.tar.gz | tar xvz -C /usr/bin/
- crane auth login -u $REGISTRY_USER -p $REGISTRY_PASS $REGISTRY_URL
- crane push maptest-bot.tar $REGISTRY_URL/strafesnet/maptest-bot:latest
- crane push maptest-bot.tar $REGISTRY_URL/strafesnet/maptest-bot:master-$DRONE_BUILD_NUMBER
environment:
REGISTRY_URL:
from_secret: REGISTRY_URL
REGISTRY_USER:
from_secret: REGISTRY_USER
REGISTRY_PASS:
from_secret: REGISTRY_PASS
when:
ref:
- refs/heads/master
- name: deploy
image: alpine/helm:latest
commands:
- mkdir ~/.kube && echo "$KUBE_CONF_DEV" > ~/.kube/config && chmod 600 ~/.kube/config
- helm upgrade -i --namespace=strafesnet-dev maptest-bot --set config="$(echo $APP_CONFIG | base64 -w0)" --set image.tag=master-$DRONE_BUILD_NUMBER chart
environment:
APP_CONFIG:
from_secret: APP_CONFIG
KUBE_CONF_DEV:
from_secret: KUBE_CONF_DEV
when:
ref:
- refs/heads/master
trigger:
ref:
- refs/heads/master
- refs/pull/*/head

42
.drone.yml Normal file
View File

@ -0,0 +1,42 @@
---
kind: pipeline
type: docker
platform:
os: linux
arch: amd64
steps:
- name: image
image: plugins/docker
settings:
registry: registry.itzana.me
repo: registry.itzana.me/strafesnet/maptest-bot
tags:
- ${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
- ${DRONE_BRANCH}
username:
from_secret: REGISTRY_USER
password:
from_secret: REGISTRY_PASS
when:
branch:
- master
- name: deploy
image: argoproj/argocd:latest
commands:
- argocd login --grpc-web cd.stricity.com --username $USERNAME --password $PASSWORD
- argocd app --grpc-web set ${DRONE_BRANCH}-maptest-bot --kustomize-image registry.itzana.me/strafesnet/maptest-bot:${DRONE_BRANCH}-${DRONE_BUILD_NUMBER}
environment:
USERNAME:
from_secret: ARGO_USER
PASSWORD:
from_secret: ARGO_PASS
when:
branch:
- master
trigger:
ref:
- refs/heads/master

View File

@ -1,23 +0,0 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@ -1,24 +0,0 @@
apiVersion: v2
name: maptest-bot
description: Map test bot helm chart
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"

View File

@ -1,62 +0,0 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "maptest-bot.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "maptest-bot.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "maptest-bot.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "maptest-bot.labels" -}}
helm.sh/chart: {{ include "maptest-bot.chart" . }}
{{ include "maptest-bot.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "maptest-bot.selectorLabels" -}}
app.kubernetes.io/name: {{ include "maptest-bot.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "maptest-bot.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "maptest-bot.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@ -1,28 +0,0 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "maptest-bot.fullname" . }}
labels:
{{- include "maptest-bot.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "maptest-bot.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View File

@ -1,9 +0,0 @@
apiVersion: v1
data:
config.json: {{ .Values.config | quote }}
kind: Secret
metadata:
name: {{ include "maptest-bot.fullname" . }}-config
labels:
{{- include "maptest-bot.labels" . | nindent 4 }}
type: Opaque

View File

@ -1,83 +0,0 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ include "maptest-bot.fullname" . }}
labels:
{{- include "maptest-bot.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "maptest-bot.selectorLabels" . | nindent 6 }}
serviceName: {{ include "maptest-bot.fullname" . }}
volumeClaimTemplates:
- metadata:
name: map-submits
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 1Gi
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "maptest-bot.selectorLabels" . | nindent 8 }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
command: ["node"]
args: ["bot.js"]
volumeMounts:
- name: config
mountPath: "/app/config"
readOnly: true
- name: map-submits
mountPath: "/app/files"
initContainers:
- name: {{ .Chart.Name }}-init
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
command: ["node"]
args: ["deploy-commands.js"]
volumeMounts:
- name: config
mountPath: "/app/config"
readOnly: true
volumes:
- name: config
secret:
secretName: {{ include "maptest-bot.fullname" . }}-config
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@ -1,56 +0,0 @@
# Default values for maptest-bot.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: registry.itzana.me/strafesnet/maptest-bot
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"
imagePullSecrets:
- name: registry-itzaname
nameOverride: ""
fullnameOverride: ""
podAnnotations: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
nodeSelector: {}
tolerations: []
affinity: {}
config: ""

View File

@ -2,13 +2,13 @@ const { SlashCommandBuilder } = require('@discordjs/builders');
const { parse } = require("csv-parse/sync"); const { parse } = require("csv-parse/sync");
const fs = require('node:fs'); const fs = require('node:fs');
const noblox = require("noblox.js"); const noblox = require("noblox.js");
const axios = require("axios").default const axios = require("axios").default;
async function robloxUserFromDiscord(id) { async function robloxUserFromDiscord(id) {
if (isNaN(id)) return undefined; if (isNaN(id)) return undefined;
try { try {
const res = await axios.get(`https://verify.eryn.io/api/user/${id}`) const res = await axios.get(`https://api.fiveman1.net/v1/users/${id}`);
return res.data.robloxId return res.data.result.robloxId;
} catch (error) { } catch (error) {
return undefined; return undefined;
} }
@ -17,17 +17,17 @@ async function robloxUserFromDiscord(id) {
async function robloxUsernameFromId(id) { async function robloxUsernameFromId(id) {
if (isNaN(id)) return undefined; if (isNaN(id)) return undefined;
try { try {
const res = await axios.get(`https://users.roblox.com/v1/users/${id}`) const res = await axios.get(`https://users.roblox.com/v1/users/${id}`);
return res.data.name return res.data.name;
} catch (error) { } catch (error) {
return undefined; return undefined;
} }
} }
async function execute(interaction) { async function execute(interaction) {
const userId = await robloxUserFromDiscord(interaction.user.id) const userId = await robloxUserFromDiscord(interaction.user.id);
if (!userId) { if (!userId) {
const msg = "You don't have a Roblox account linked with your Discord account. Visit https://verify.eryn.io/"; const msg = "You don't have a Roblox account linked with your Discord account. Use !link with rbhop dog to link your account.";
await interaction.reply({content: msg, ephemeral: true}); await interaction.reply({content: msg, ephemeral: true});
return; return;
} }