From 8c7e41b21be7b485d6df9f1e0ea6a259cfdf4f7a Mon Sep 17 00:00:00 2001 From: Dunemask Date: Sat, 24 Aug 2024 16:41:52 -0600 Subject: [PATCH 1/7] [FIX] Use New Cairo System --- lib/database/migrations/1_create_servers_table.sql | 2 +- lib/routes/auth-route.js | 5 ++++- lib/routes/middlewares/auth-middleware.js | 10 +++++----- src/util/auth.js | 4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/lib/database/migrations/1_create_servers_table.sql b/lib/database/migrations/1_create_servers_table.sql index fe3f357..6386fc5 100644 --- a/lib/database/migrations/1_create_servers_table.sql +++ b/lib/database/migrations/1_create_servers_table.sql @@ -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', diff --git a/lib/routes/auth-route.js b/lib/routes/auth-route.js index 8409975..638e163 100644 --- a/lib/routes/auth-route.js +++ b/lib/routes/auth-route.js @@ -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}`, ); } diff --git a/lib/routes/middlewares/auth-middleware.js b/lib/routes/middlewares/auth-middleware.js index 37fe39c..5758cb4 100644 --- a/lib/routes/middlewares/auth-middleware.js +++ b/lib/routes/middlewares/auth-middleware.js @@ -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) => { diff --git a/src/util/auth.js b/src/util/auth.js index f25a6bb..69b9d8c 100644 --- a/src/util/auth.js +++ b/src/util/auth.js @@ -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", { From 6e9c71568d1031664e3a8ec0de964b6e313aa577 Mon Sep 17 00:00:00 2001 From: Dunemask Date: Sun, 25 Aug 2024 10:56:04 -0600 Subject: [PATCH 2/7] [CHORE] Adjust Actions For Deployment --- .forgejo/workflows/deploy-edge-proxy.yml | 31 +++++++++++++++++ .forgejo/workflows/deploy-edge.yml | 44 ++++++++++++++++++++++++ .forgejo/workflows/qa-api-tests.yml | 42 ++++++++++++++++++++++ .forgejo/workflows/s3-repo-backup.yml | 31 +++++++++++++++++ .gitea/workflows/deploy-edge-proxy.yml | 31 ----------------- .gitea/workflows/deploy-edge.yml | 43 ----------------------- .gitea/workflows/qa-api-tests.yml | 42 ---------------------- .gitea/workflows/s3-repo-backup.yml | 31 ----------------- 8 files changed, 148 insertions(+), 147 deletions(-) create mode 100644 .forgejo/workflows/deploy-edge-proxy.yml create mode 100644 .forgejo/workflows/deploy-edge.yml create mode 100644 .forgejo/workflows/qa-api-tests.yml create mode 100644 .forgejo/workflows/s3-repo-backup.yml delete mode 100644 .gitea/workflows/deploy-edge-proxy.yml delete mode 100644 .gitea/workflows/deploy-edge.yml delete mode 100644 .gitea/workflows/qa-api-tests.yml delete mode 100644 .gitea/workflows/s3-repo-backup.yml diff --git a/.forgejo/workflows/deploy-edge-proxy.yml b/.forgejo/workflows/deploy-edge-proxy.yml new file mode 100644 index 0000000..87125e3 --- /dev/null +++ b/.forgejo/workflows/deploy-edge-proxy.yml @@ -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" \ No newline at end of file diff --git a/.forgejo/workflows/deploy-edge.yml b/.forgejo/workflows/deploy-edge.yml new file mode 100644 index 0000000..5e9500d --- /dev/null +++ b/.forgejo/workflows/deploy-edge.yml @@ -0,0 +1,44 @@ +name: Deploy USW-MC +run-name: ${{ forgejo.actor }} Deploy USW-MC +on: + push: + branches: [ master ] + +env: + GARDEN_DEPLOY_ACTION: minecluster + +jobs: + deploy-edge: + steps: + # Configure proper kubeconfig (Used when cluster does not match the edge environment) + # - name: Get usw-mc deployment kubeconfig + # uses: https://forgejo.dunemask.dev/elysium/elysium-actions@infisical-env + # with: + # infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }} + # infisical-project: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }} + # secret-envs: edge + # secret-paths: /kubernetes + # Setup Oasis + - name: Oasis Setup + uses: https://forgejo.dunemask.dev/elysium/elysium-actions@oasis-setup-auto + with: + deploy-env: edge + infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }} + infisical-project: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }} + extra-secret-paths: /dashboard + extra-secret-envs: edge + # Deploy to Edge + - name: Deploy to Edge env + run: garden deploy $GARDEN_DEPLOY_ACTION --force --force-build --env usw-edge + working-directory: ${{ env.OASIS_WORKSPACE }} + # 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://forgejo.dunemask.dev/elysium/elysium-actions@discord-status + with: + status: ${{ job.status }} + channel: deployments + header: DEPLOY MC + additional-content: "Minecluster Server Manager Deployment" \ No newline at end of file diff --git a/.forgejo/workflows/qa-api-tests.yml b/.forgejo/workflows/qa-api-tests.yml new file mode 100644 index 0000000..596e11a --- /dev/null +++ b/.forgejo/workflows/qa-api-tests.yml @@ -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}}`" + \ No newline at end of file diff --git a/.forgejo/workflows/s3-repo-backup.yml b/.forgejo/workflows/s3-repo-backup.yml new file mode 100644 index 0000000..d672972 --- /dev/null +++ b/.forgejo/workflows/s3-repo-backup.yml @@ -0,0 +1,31 @@ +# 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 }}." diff --git a/.gitea/workflows/deploy-edge-proxy.yml b/.gitea/workflows/deploy-edge-proxy.yml deleted file mode 100644 index c961b21..0000000 --- a/.gitea/workflows/deploy-edge-proxy.yml +++ /dev/null @@ -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" \ No newline at end of file diff --git a/.gitea/workflows/deploy-edge.yml b/.gitea/workflows/deploy-edge.yml deleted file mode 100644 index 9748db7..0000000 --- a/.gitea/workflows/deploy-edge.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Deploy USW-MC -run-name: ${{ gitea.actor }} Deploy USW-MC -on: - push: - branches: [ master ] - -env: - GARDEN_DEPLOY_ACTION: minecluster - -jobs: - deploy-edge: - steps: - # Configure proper kubeconfig - - name: Get usw-mc deployment kubeconfig - uses: https://gitea.dunemask.dev/elysium/elysium-actions@infisical-env - with: - infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }} - secret-envs: edge - secret-paths: /kubernetes - # 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 }} - extra-secret-paths: /alexandria - 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 - working-directory: ${{ env.OASIS_WORKSPACE }} - env: - 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 - with: - status: ${{ job.status }} - channel: deployments - header: DEPLOY MC - additional-content: "Minecluster Server Manager Deployment" \ No newline at end of file diff --git a/.gitea/workflows/qa-api-tests.yml b/.gitea/workflows/qa-api-tests.yml deleted file mode 100644 index 8222cdf..0000000 --- a/.gitea/workflows/qa-api-tests.yml +++ /dev/null @@ -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}}`" - \ No newline at end of file diff --git a/.gitea/workflows/s3-repo-backup.yml b/.gitea/workflows/s3-repo-backup.yml deleted file mode 100644 index 77b0702..0000000 --- a/.gitea/workflows/s3-repo-backup.yml +++ /dev/null @@ -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 }}." From f22b9a3262564444b5343a21cb7bab234b971d92 Mon Sep 17 00:00:00 2001 From: Dunemask Date: Sun, 25 Aug 2024 11:18:08 -0600 Subject: [PATCH 3/7] [FIX} Fix Minecluster Deployment Again --- .forgejo/workflows/deploy-edge.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.forgejo/workflows/deploy-edge.yml b/.forgejo/workflows/deploy-edge.yml index 5e9500d..b4489d8 100644 --- a/.forgejo/workflows/deploy-edge.yml +++ b/.forgejo/workflows/deploy-edge.yml @@ -1,8 +1,8 @@ name: Deploy USW-MC run-name: ${{ forgejo.actor }} Deploy USW-MC on: - push: - branches: [ master ] + push: + branches: [master] env: GARDEN_DEPLOY_ACTION: minecluster @@ -11,13 +11,13 @@ jobs: deploy-edge: steps: # Configure proper kubeconfig (Used when cluster does not match the edge environment) - # - name: Get usw-mc deployment kubeconfig - # uses: https://forgejo.dunemask.dev/elysium/elysium-actions@infisical-env - # with: - # infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }} - # infisical-project: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }} - # secret-envs: edge - # secret-paths: /kubernetes + - name: Get usw-mc deployment kubeconfig + uses: https://forgejo.dunemask.dev/elysium/elysium-actions@infisical-env + with: + infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }} + infisical-project: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }} + secret-envs: edge + secret-paths: /kubernetes/usw-mc # Setup Oasis - name: Oasis Setup uses: https://forgejo.dunemask.dev/elysium/elysium-actions@oasis-setup-auto @@ -31,8 +31,8 @@ jobs: - name: Deploy to Edge env run: garden deploy $GARDEN_DEPLOY_ACTION --force --force-build --env usw-edge working-directory: ${{ env.OASIS_WORKSPACE }} - # env: # (Used when cluster does not match the edge environment) - # 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() @@ -41,4 +41,4 @@ jobs: status: ${{ job.status }} channel: deployments header: DEPLOY MC - additional-content: "Minecluster Server Manager Deployment" \ No newline at end of file + additional-content: "Minecluster Server Manager Deployment" From b2f093111f2ce08de37a67ede851ae44a241433e Mon Sep 17 00:00:00 2001 From: Dunemask Date: Sun, 25 Aug 2024 11:28:29 -0600 Subject: [PATCH 4/7] [CHORE] Adjust Action Inputs --- .forgejo/workflows/deploy-edge.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/deploy-edge.yml b/.forgejo/workflows/deploy-edge.yml index b4489d8..afb0c78 100644 --- a/.forgejo/workflows/deploy-edge.yml +++ b/.forgejo/workflows/deploy-edge.yml @@ -15,7 +15,7 @@ jobs: uses: https://forgejo.dunemask.dev/elysium/elysium-actions@infisical-env with: infisical-token: ${{ secrets.INFISICAL_ELYSIUM_EDGE_READ_TOKEN }} - infisical-project: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }} + project-id: ${{ vars.INFISICAL_DEPLOYMENTS_PROJECT_ID }} secret-envs: edge secret-paths: /kubernetes/usw-mc # Setup Oasis From 968aa1fc741062344b9372abe1b15f3f2ab86563 Mon Sep 17 00:00:00 2001 From: Dunemask Date: Sun, 25 Aug 2024 11:34:55 -0600 Subject: [PATCH 5/7] [CHORE] Adjust Action Inputs --- lib/k8s/k8s-config.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/k8s/k8s-config.js b/lib/k8s/k8s-config.js index 4167552..d481f77 100644 --- a/lib/k8s/k8s-config.js +++ b/lib/k8s/k8s-config.js @@ -7,6 +7,8 @@ try { kc.loadFromString(Buffer.from(envConfig, "base64").toString("utf8")); else kc.loadFromDefault(); } catch (e) { + console.error("There was an issue loading the config from an envar! Using default permissions!"); + console.error(e); kc.loadFromDefault(); } export default kc; From 27b11fcd502c815d7489b3914c390751306f99dd Mon Sep 17 00:00:00 2001 From: Dunemask Date: Sun, 25 Aug 2024 11:52:25 -0600 Subject: [PATCH 6/7] [FIX] Infer Current Context --- .gitignore | 1 + lib/k8s/k8s-config.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index d570088..5c86a6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ +.env diff --git a/lib/k8s/k8s-config.js b/lib/k8s/k8s-config.js index d481f77..cbe55b6 100644 --- a/lib/k8s/k8s-config.js +++ b/lib/k8s/k8s-config.js @@ -7,8 +7,8 @@ try { kc.loadFromString(Buffer.from(envConfig, "base64").toString("utf8")); else kc.loadFromDefault(); } catch (e) { - console.error("There was an issue loading the config from an envar! Using default permissions!"); - console.error(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; From c4882cb22fc93100ce6c204cee71c68e94e650c7 Mon Sep 17 00:00:00 2001 From: Dunemask Date: Sun, 25 Aug 2024 16:46:21 -0600 Subject: [PATCH 7/7] [CHORE] Adjust Forgejo Actions --- .forgejo/workflows/s3-repo-backup.yml | 46 ++++++++++----------------- 1 file changed, 16 insertions(+), 30 deletions(-) diff --git a/.forgejo/workflows/s3-repo-backup.yml b/.forgejo/workflows/s3-repo-backup.yml index d672972..4e4e7fd 100644 --- a/.forgejo/workflows/s3-repo-backup.yml +++ b/.forgejo/workflows/s3-repo-backup.yml @@ -1,31 +1,17 @@ -# name: S3 Repo Backup -# run-name: ${{ gitea.actor }} S3 Repo Backup -# on: -# push: -# branches: [ master ] +name: S3 Repo Backup +run-name: ${{ forgejo.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 }}." +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 }}."