Compare commits

...
Sign in to create a new pull request.

7 commits

Author SHA1 Message Date
c4882cb22f [CHORE] Adjust Forgejo Actions
All checks were successful
S3 Repo Backup / s3-repo-backup (push) Successful in 19s
Deploy USW-MC / deploy-edge (push) Successful in 2m21s
2024-08-25 16:46:21 -06:00
27b11fcd50 [FIX] Infer Current Context
All checks were successful
Deploy USW-MC / deploy-edge (push) Successful in 2m7s
2024-08-25 11:52:25 -06:00
968aa1fc74 [CHORE] Adjust Action Inputs
Some checks failed
Deploy USW-MC / deploy-edge (push) Failing after 6m40s
2024-08-25 11:34:55 -06:00
b2f093111f [CHORE] Adjust Action Inputs
Some checks failed
Deploy USW-MC / deploy-edge (push) Has been cancelled
2024-08-25 11:28:29 -06:00
f22b9a3262 [FIX} Fix Minecluster Deployment Again
Some checks failed
Deploy USW-MC / deploy-edge (push) Failing after 10s
2024-08-25 11:18:08 -06:00
6e9c71568d [CHORE] Adjust Actions For Deployment
All checks were successful
Deploy USW-MC / deploy-edge (push) Successful in 2m3s
2024-08-25 10:56:04 -06:00
8c7e41b21b [FIX] Use New Cairo System
Some checks failed
Deploy USW-MC / deploy-edge (push) Failing after 2s
Deploy Edge Proxy / deploy-edge (push) Failing after 2s
S3 Repo Backup / s3-repo-backup (push) Failing after 5s
2024-08-24 16:41:52 -06:00
13 changed files with 120 additions and 127 deletions

View file

@ -0,0 +1,31 @@
# name: Deploy Edge Proxy
# run-name: ${{ gitea.actor }} Deploy Edge Proxy
# on:
# push:
# branches: [ master ]
# env:
# GARDEN_DEPLOY_ACTION: minecluster-proxy
# jobs:
# deploy-edge:
# steps:
# # Setup Oasis
# - name: Oasis Setup
# uses: https://gitea.dunemask.dev/elysium/elysium-actions@oasis-setup-auto
# with:
# deploy-env: edge
# infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }}
# # Deploy to Edge Cluster
# - name: Deploy to Edge Cluster
# run: garden deploy $GARDEN_DEPLOY_ACTION --force --force-build --env usw-edge
# working-directory: ${{ env.OASIS_WORKSPACE }}
# # Alert via Discord
# - name: Discord Alert
# if: always()
# uses: https://gitea.dunemask.dev/elysium/elysium-actions@discord-status
# with:
# status: ${{ job.status }}
# channel: deployments
# header: DEPLOY EDGE
# additional-content: "Minecluster Proxy"

View file

@ -1,8 +1,8 @@
name: Deploy USW-MC
run-name: ${{ gitea.actor }} Deploy USW-MC
run-name: ${{ forgejo.actor }} Deploy USW-MC
on:
push:
branches: [ master ]
push:
branches: [master]
env:
GARDEN_DEPLOY_ACTION: minecluster
@ -10,34 +10,35 @@ env:
jobs:
deploy-edge:
steps:
# Configure proper kubeconfig
# Configure proper kubeconfig (Used when cluster does not match the edge environment)
- name: Get usw-mc deployment kubeconfig
uses: https://gitea.dunemask.dev/elysium/elysium-actions@infisical-env
uses: https://forgejo.dunemask.dev/elysium/elysium-actions@infisical-env
with:
infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }}
project-id: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }}
secret-envs: edge
secret-paths: /kubernetes
secret-paths: /kubernetes/usw-mc
# Setup Oasis
- name: Oasis Setup
uses: https://gitea.dunemask.dev/elysium/elysium-actions@oasis-setup-auto
uses: https://forgejo.dunemask.dev/elysium/elysium-actions@oasis-setup-auto
with:
deploy-env: edge
infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }}
extra-secret-paths: /alexandria
infisical-project: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }}
extra-secret-paths: /dashboard
extra-secret-envs: edge
kubeconfig: ${{ env.KUBERNETES_CONFIG_USW_MC }}
# Deploy to Edge
- name: Deploy to Edge env
run: garden deploy $GARDEN_DEPLOY_ACTION --force --force-build --env usw-mc
run: garden deploy $GARDEN_DEPLOY_ACTION --force --force-build --env usw-edge
working-directory: ${{ env.OASIS_WORKSPACE }}
env:
MCL_KUBECONFIG: ${{ env.KUBERNETES_CONFIG_USW_MC }}
env: # (Used when cluster does not match the edge environment)
MCL_KUBECONFIG: ${{ env.KUBERNETES_CONFIG_USW_MC }}
# Alert via Discord
- name: Discord Alert
if: always()
uses: https://gitea.dunemask.dev/elysium/elysium-actions@discord-status
uses: https://forgejo.dunemask.dev/elysium/elysium-actions@discord-status
with:
status: ${{ job.status }}
channel: deployments
header: DEPLOY MC
additional-content: "Minecluster Server Manager Deployment"
additional-content: "Minecluster Server Manager Deployment"

View file

@ -0,0 +1,42 @@
# name: QA API Tests
# run-name: ${{ gitea.actor }} QA API Test
# on:
# pull_request:
# branches: [ master ]
# env:
# REPO_DIR: ${{ gitea.workspace }}/minecluster
# GARDEN_LINK_ACTION: build.minecluster-image
# jobs:
# qa-api-tests:
# steps:
# # Setup Oasis
# - name: Oasis Setup
# uses: https://gitea.dunemask.dev/elysium/elysium-actions@oasis-setup-auto
# with:
# deploy-env: ci
# infisical-token: ${{ secrets.INFISICAL_ELYSIUM_CI_READ_TOKEN }}
# # Test Code
# - name: Checkout repository
# uses: actions/checkout@v3
# with:
# path: ${{ env.REPO_DIR }}
# # Garden link
# - name: Link Repo code to Garden
# run: garden link action $GARDEN_LINK_ACTION $REPO_DIR --env usw-ci --var cubit-projects=cairo,minecluster
# working-directory: ${{ env.OASIS_WORKSPACE }}
# # Cubit CI Tests
# - name: Run Cubit tests in CI env
# run: garden workflow qa-api-tests --env usw-ci --var ci-ttl=25m
# working-directory: ${{ env.OASIS_WORKSPACE }}
# # Discord Alert
# - name: Discord Alert
# if: always()
# uses: https://gitea.dunemask.dev/elysium/elysium-actions@discord-status
# with:
# status: ${{ job.status }}
# channel: ci
# header: QA API Tests
# additional-content: "CI Namespace: `${{env.CI_NAMESPACE}}`"

View file

@ -0,0 +1,17 @@
name: S3 Repo Backup
run-name: ${{ forgejo.actor }} S3 Repo Backup
on:
push:
branches: [ master ]
jobs:
s3-repo-backup:
steps:
- name: S3 Backup
uses: https://forgejo.dunemask.dev/elysium/elysium-actions@s3-backup
with:
infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }}
infisical-project: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }}
- name: Status Alert
if: always()
run: echo "The Job ended with status ${{ job.status }}."

View file

@ -1,31 +0,0 @@
name: Deploy Edge Proxy
run-name: ${{ gitea.actor }} Deploy Edge Proxy
on:
push:
branches: [ master ]
env:
GARDEN_DEPLOY_ACTION: minecluster-proxy
jobs:
deploy-edge:
steps:
# Setup Oasis
- name: Oasis Setup
uses: https://gitea.dunemask.dev/elysium/elysium-actions@oasis-setup-auto
with:
deploy-env: edge
infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }}
# Deploy to Edge Cluster
- name: Deploy to Edge Cluster
run: garden deploy $GARDEN_DEPLOY_ACTION --force --force-build --env usw-edge
working-directory: ${{ env.OASIS_WORKSPACE }}
# Alert via Discord
- name: Discord Alert
if: always()
uses: https://gitea.dunemask.dev/elysium/elysium-actions@discord-status
with:
status: ${{ job.status }}
channel: deployments
header: DEPLOY EDGE
additional-content: "Minecluster Proxy"

View file

@ -1,42 +0,0 @@
name: QA API Tests
run-name: ${{ gitea.actor }} QA API Test
on:
pull_request:
branches: [ master ]
env:
REPO_DIR: ${{ gitea.workspace }}/minecluster
GARDEN_LINK_ACTION: build.minecluster-image
jobs:
qa-api-tests:
steps:
# Setup Oasis
- name: Oasis Setup
uses: https://gitea.dunemask.dev/elysium/elysium-actions@oasis-setup-auto
with:
deploy-env: ci
infisical-token: ${{ secrets.INFISICAL_ELYSIUM_CI_READ_TOKEN }}
# Test Code
- name: Checkout repository
uses: actions/checkout@v3
with:
path: ${{ env.REPO_DIR }}
# Garden link
- name: Link Repo code to Garden
run: garden link action $GARDEN_LINK_ACTION $REPO_DIR --env usw-ci --var cubit-projects=cairo,minecluster
working-directory: ${{ env.OASIS_WORKSPACE }}
# Cubit CI Tests
- name: Run Cubit tests in CI env
run: garden workflow qa-api-tests --env usw-ci --var ci-ttl=25m
working-directory: ${{ env.OASIS_WORKSPACE }}
# Discord Alert
- name: Discord Alert
if: always()
uses: https://gitea.dunemask.dev/elysium/elysium-actions@discord-status
with:
status: ${{ job.status }}
channel: ci
header: QA API Tests
additional-content: "CI Namespace: `${{env.CI_NAMESPACE}}`"

View file

@ -1,31 +0,0 @@
name: S3 Repo Backup
run-name: ${{ gitea.actor }} S3 Repo Backup
on:
push:
branches: [ master ]
env:
S3_BACKUP_ENDPOINT: https://s3.dunemask.dev
S3_BACKUP_KEY_ID: gitea-repo-backup
S3_BACKUP_KEY: ${{ secrets.S3_REPO_BACKUP_KEY }}
REPO_DIR: ${{ gitea.workspace }}/${{ gitea.respository }}
jobs:
s3-repo-backup:
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
path: ${{ env.REPO_DIR }}
- name: S3 Backup
uses: peter-evans/s3-backup@v1
env:
ACCESS_KEY_ID: ${{ env.S3_BACKUP_KEY_ID }}
SECRET_ACCESS_KEY: ${{ env.S3_BACKUP_KEY }}
MIRROR_SOURCE: ${{ env.REPO_DIR }}
MIRROR_TARGET: backups/gitea-repositories/${{ gitea.repository }}
STORAGE_SERVICE_URL: ${{env.S3_BACKUP_ENDPOINT}}
with:
args: --overwrite --remove
- name: Status Alert
if: always()
run: echo "The Job ended with status ${{ job.status }}."

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
node_modules/
.env

View file

@ -1,7 +1,7 @@
CREATE SEQUENCE servers_id_seq;
CREATE TABLE servers (
id bigint NOT NULL DEFAULT nextval('servers_id_seq') PRIMARY KEY,
owner_cairo_id bigint,
owner_cairo_id varchar(63),
host varchar(255) DEFAULT NULL,
name varchar(255) DEFAULT NULL,
version varchar(63) DEFAULT 'latest',

View file

@ -9,4 +9,6 @@ try {
} catch (e) {
kc.loadFromDefault();
}
if(kc.contexts.length === 1) kc.setCurrentContext(kc.contexts[0].name);
if(!kc.currentContext) throw new Error("Could not infer current context! Please set it manually in the Kubeconfig!");
export default kc;

View file

@ -2,11 +2,14 @@ import { Router } from "express";
import cairoAuthMiddleware from "./middlewares/auth-middleware.js";
const router = Router();
const cairoProjectId = process.env.MCL_CAIRO_PROJECT;
if(!cairoProjectId) throw Error("Cairo Project Required!");
const ok = (_r, res) => res.sendStatus(200);
function cairoRedirect(req, res) {
res.redirect(
`${process.env.MCL_CAIRO_URL}/cairo/auth?redirectUri=${req.query.redirectUri}`,
`${process.env.MCL_CAIRO_URL}/cairo/authenticate?redirectUri=${req.query.redirectUri}&projectId=${cairoProjectId}`,
);
}

View file

@ -4,12 +4,12 @@ import bearerTokenMiddleware from "express-bearer-token";
import { ERR, VERB } from "../../util/logging.js";
// Constants
const { MCL_CAIRO_URL } = process.env;
const { MCL_CAIRO_URL, MCL_CAIRO_PROJECT } = process.env;
const cairoAuthMiddleware = Router();
const cairoAuthenticate = async (token) => {
const config = { headers: { Authorization: `Bearer ${token}` } };
return fetch(`${MCL_CAIRO_URL}/api/user/info`, config).then(async (res) => {
return fetch(`${MCL_CAIRO_URL}/api/${MCL_CAIRO_PROJECT}/auth/credentials`, config).then(async (res) => {
if (res.status >= 300) {
const errorMessage = await res
.json()
@ -30,9 +30,9 @@ const cairoAuthHandler = (req, res, next) => {
cairoAuthenticate(req.token)
.then((authData) => {
console.log(authData);
if (!authData.id)
throw Error(`Cairo didn't return the expected data! ${authData.id}`);
req.cairoId = authData.id;
if (!authData?.user?.id)
throw Error(`Cairo didn't return the expected data! ${authData?.user?.id}`);
req.cairoId = authData?.user?.id;
})
.then(() => next())
.catch((err) => {

View file

@ -1,8 +1,8 @@
import { useState, useEffect } from "react";
import { useSearchParams } from "react-router-dom";
const tokenStorageName = "cairoAuthToken";
const tokenQuery = "cairoAuthToken";
const tokenStorageName = "cairoUserToken";
const tokenQuery = "cairoUserToken";
const verifyAuth = (authToken) =>
fetch("/api/auth/verify", {