Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current version on the site #42

Open
wants to merge 12 commits into
base: legacy
Choose a base branch
from
88 changes: 88 additions & 0 deletions .github/workflows/build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: lainTSX build and deploy
run-name: Run ${{ github.run_id }} attempt ${{ github.run_attempt }}
on: [push]
jobs:
creating-npm-cache:
runs-on: ubuntu-latest
container:
image: node:16-buster-slim
steps:
- name: Check out repository code
uses: actions/checkout@v3
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install NPM Dependencies
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: npm ci

build-and-deploy:
needs: creating-npm-cache
runs-on: [self-hosted, linux, x64]
container:
image: ${{ vars.LAINTSX_BUILDER_DOCKER_IMAGE }}
steps:
- name: Check out repository code
uses: actions/checkout@v3
with:
submodules: recursive
- name: Cache node modules
id: cache-nodemodules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# caching node_modules
path: node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Extract static files
run: find /opt/extract/ -name *.tar.gz -exec tar xf {} \;
- name: Install Dependencies again on cached dir (faster)
run: npm ci
- name: Build
run: npm run build --verbose
- name: Copy current subtitles to the build
run: cp -r src/static/media/webvtt/ build/ && rm -rf build/webvtt/.git
- name: Set outputs
id: vars
run: |
BUILD_VERSION=$(date +%Y-%m-%d_%H-%M-%S)-$(git rev-parse --short HEAD)
echo ${BUILD_VERSION} | tee build/version.txt
echo "filename=lainTSX-${BUILD_VERSION}.zip" >> $GITHUB_OUTPUT
- name: Redbean download
run: |
curl --fail \
-H "Authorization: Bearer ${{ secrets.UPLOAD_KEY }}" \
${{ secrets.DEPLOY_URL }}redbean-latest.zip -o build.zip
- name: Pack
run: cd build && zip --quiet --recurse-paths ../build.zip * ; cd ..
- name: Rename
run: mv build.zip "${{ steps.vars.outputs.filename }}"
- name: Upload
run: |
curl --fail \
-H "Authorization: Bearer ${{ secrets.UPLOAD_KEY }}" \
-F file=@${{ steps.vars.outputs.filename }} \
${{ secrets.DEPLOY_URL }}
- name: Deploy to test server
run: |
curl --fail \
-H "Authorization: Bearer ${{ secrets.UPLOAD_KEY }}" \
${{ secrets.DEPLOY_URL }}${{ steps.vars.outputs.filename }}?action=testserver
- name: Self Hosted Runner Post Job Cleanup Action
uses: TooMuch4U/[email protected]

2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "webvtt"]
path = src/static/media/webvtt
url = https://github.com/laingame-net/lainvtt
url = git@github.com:laingame-net/lainvtt.git
38 changes: 20 additions & 18 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
FROM node:15.12.0-alpine AS builder
FROM node:15.12.0-alpine

RUN apk add openjdk11 ffmpeg git tar zip curl

RUN --mount=type=bind,source=.,target=/src,rw \
set -x && \
mkdir -p /opt/extract && \
cd /src/scripts/extract && \
NODE_PATH=/opt/extract/node_modules npm i && \
NODE_PATH=/opt/extract/node_modules node extract.mjs 2>&1 | tee /opt/extract/build.log && \
cd /src && \
tar czf /opt/extract/0_static_files_from_extractor.tar.gz \
--exclude=src/static/media/webvtt \
--exclude=src/static/sfx/index.ts \
--exclude=src/static/css \
--exclude=src/static/font \
src/static/ && \
cp -f scripts/extract/discs/*.tar.gz /opt/extract/ && \
cp -f scripts/extract/*.log /opt/extract/ && \
rm -rf /tmp/*

WORKDIR /app

COPY scripts/ ./scripts
COPY package-lock.json .
COPY package.json .

RUN npm i

COPY . .

RUN npm run build

RUN ls build/

FROM nginx:alpine

COPY --from=builder /app/build/ /usr/share/nginx/html/
9 changes: 6 additions & 3 deletions scripts/extract/extract_site_images.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { spawnSync } from "child_process";
import { readFileSync, mkdirSync, writeFileSync, renameSync } from "fs";
import { readFileSync, mkdirSync, writeFileSync, copyFile } from "fs";
import { join, resolve } from "path";
import LainCompress from "./lain_compress.js";

Expand Down Expand Up @@ -40,9 +40,12 @@ export function extract_site_images(tempdir, jpsxdec_jar) {
["-jar", jpsxdec_jar, "-f", tim_file, "-static", "tim"],
{ stdio: "inherit", cwd: tempdir }
);
renameSync(
copyFile(
join(tempdir, `${index}_p0.png`),
join(output_folder, `${index}.png`)
join(output_folder, `${index}.png`),
(err) => {
if (err) { console.log("Error Found:", err); }
}
);
}
}
Expand Down
1 change: 1 addition & 0 deletions scripts/extract/extract_voice.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function extract_voice(tempdir, jpsxdec_jar) {
22050,
"-f",
"s16le",
"-n",
"-i",
tempfile,
outfile,
Expand Down
2 changes: 1 addition & 1 deletion src/components/Images.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const Images = () => {
imgTries++;
if (img[1] !== "-1") {
import(
"../static/media/images/" + activeSite + "/" + img[1] + ".png"
"../static/images/" + activeSite + "/" + img[1] + ".png"
).then((imageSrc: { default: string }) => {
imgArr.splice(parseInt(img[0]), 0, imageSrc);
if (imgTries === 3) {
Expand Down
2 changes: 2 additions & 0 deletions src/dom-components/Language.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const Language = () => {
const supportedLanguages = [
{ language: "English", code: "en" },
{ language: "French", code: "fr" },
{ language: "German", code: "de" },
{ language: "Japanese", code: "ja" },
{ language: "Korean", code: "ko" },
{ language: "Portuguese, Brazilian", code: "pt-BR"},
{ language: "Russian", code: "ru"}
Expand Down
12 changes: 12 additions & 0 deletions src/dom-components/MainPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,18 @@ const MainPage = () => {
}
credit={"French translation."}
/>{" "}
<Credit
name={
"publicdesert, Sealtyth, Doftos, dogukan57"
}
credit={"German translation."}
/>{" "}
<Credit
name={
"RadioYamashita, Dylan Del Castillo Dunn Meynell"
}
credit={"Japanese transcript."}
/>{" "}
<Credit
name={
"Cyle, Chair Broken, aeon, Mainu, karuhaku, pb29"
Expand Down
2 changes: 1 addition & 1 deletion src/static/media/webvtt
Submodule webvtt updated 3185 files