From 9ece801bff0b5ef606b48b8c8b8fac43fdba0ad8 Mon Sep 17 00:00:00 2001 From: Daniel <790119+DanTheMan827@users.noreply.github.com> Date: Tue, 23 Jul 2024 10:33:48 -0500 Subject: [PATCH] Add script and workflow to generate core qmods --- .github/workflows/qmods.yml | 54 +++++++++++++++++++ .gitignore | 1 + .vscode/extensions.json | 5 ++ .vscode/settings.json | 7 +++ build_coremods.ts | 104 ++++++++++++++++++++++++++++++++++++ 5 files changed, 171 insertions(+) create mode 100644 .github/workflows/qmods.yml create mode 100644 .gitignore create mode 100644 .vscode/extensions.json create mode 100644 .vscode/settings.json create mode 100755 build_coremods.ts diff --git a/.github/workflows/qmods.yml b/.github/workflows/qmods.yml new file mode 100644 index 0000000..dc95151 --- /dev/null +++ b/.github/workflows/qmods.yml @@ -0,0 +1,54 @@ +# Simple workflow for deploying static content to GitHub Pages +name: Build and deploy qmods + +on: + # Runs on pushes targeting the default branch + push: + branches: ["main"] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: true + +jobs: + # Single deploy job since we're just deploying + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Pages + uses: actions/configure-pages@v5 + + - name: Install Deno + uses: denoland/setup-deno@v1 + with: + deno-version: v1.x + + - name: Build core qmods + run: ./build_coremods.ts + + - name: Upload artifact + uses: actions/upload-pages-artifact@v3 + with: + # Upload entire repository + path: 'qmods' + + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ae25cc8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +qmod/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..3bfc872 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "denoland.vscode-deno" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..bed5519 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,7 @@ +{ + "deno.enable": true, + "editor.formatOnSave": true, + "files.trimTrailingWhitespace": true, + "files.insertFinalNewline": true, + "files.trimFinalNewlines": true +} diff --git a/build_coremods.ts b/build_coremods.ts new file mode 100755 index 0000000..8794918 --- /dev/null +++ b/build_coremods.ts @@ -0,0 +1,104 @@ +#!/bin/env -S deno run --allow-read --allow-write --allow-run + +// Import required modules +import { join } from "https://deno.land/std@0.224.0/path/mod.ts"; +import { compress } from "https://deno.land/x/zip@v1.2.5/mod.ts"; +const { + mkdirSync, + readTextFileSync, + utimeSync, + writeTextFileSync, + removeSync, +} = Deno; + +// Define constants +const deployPath = "./qmods"; +const coreJsonPath = "./core_mods.json"; +const indexPath = join(deployPath, "index.html"); + +// Create the deployment directory +mkdirSync(deployPath, { recursive: true }); + +// Write the starting HTML tags to index.html +writeTextFileSync( + indexPath, + "