diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 88a14aa..cd09f98 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -1,4 +1,4 @@ -on: +on: push: branches: - 'master' @@ -6,7 +6,23 @@ jobs: build: runs-on: - kiljho - - self-hosted steps: - - name: Test direct issue - run: /home/michel/hello.sh \ No newline at end of file + - name: Update Service + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_KEY }} + HOST: 'rpi5' + USERNAME: 'michel' + TARGETDIR: '/mnt/drive/containers/gamesshop' + run: | + mkdir -p ~/.ssh/ + echo "$SSH_PRIVATE_KEY" | tr -d '\r' > ~/.ssh/id_rsa + chmod 600 ~/.ssh/id_rsa + + ssh-keyscan -H $HOST >> ~/.ssh/known_hosts + + # Stop service + ssh ${USERNAME}@${HOST} "cd ${TARGETDIR}/deploy && sudo docker compose down -v" + # Update Service + ssh ${USERNAME}@${HOST} "cd ${TARGETDIR} && git reset --hard origin/master && sudo ${TARGETDIR}/deploy/deploy.sh" + # Start service + ssh ${USERNAME}@${HOST} "cd ${TARGETDIR}/deploy && sudo docker compose up -d" \ No newline at end of file diff --git a/deploy/deploy.sh b/deploy/deploy.sh new file mode 100644 index 0000000..079e10c --- /dev/null +++ b/deploy/deploy.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash + +docker run -it --rm --volume "$PWD":/app -w /app node npm install +docker run -it --rm --volume "$PWD":/app -w /app node npm run build + +docker run -it --rm --volume "$PWD":/app -w /app composer composer install --ignore-platform-req=ext-gd + +docker run \ + --volume "$PWD":/app \ + --rm \ + --interactive \ + --tty \ + php:8.3-cli \ + php /app/src/php/bin/doctrine.php orm:schema-tool:update --force \ No newline at end of file diff --git a/src/js/pages/index.ts b/src/js/pages/index.ts index 1b395c6..0534169 100644 --- a/src/js/pages/index.ts +++ b/src/js/pages/index.ts @@ -95,7 +95,7 @@ async function renderDetails(childRow: HTMLDivElement, gameid: number) { childRow.removeChild(loadingContainer); const parser = new DOMParser(); - const gameDisplay: HTMLDivElement|null = parser.parseFromString(getDetailsHTML(gameData), 'text/html').body.firstChild; + const gameDisplay: HTMLDivElement|null = (parser.parseFromString(getDetailsHTML(gameData), 'text/html').body.firstChild); if (!gameDisplay) { return; @@ -103,10 +103,10 @@ async function renderDetails(childRow: HTMLDivElement, gameid: number) { gameDisplay.querySelectorAll('.claim-btn').forEach(btn => { btn.addEventListener('click', async () => { - const key = btn.closest('.key')?.dataset.keyId ?? 0; + const key = btn.closest('.key')?.dataset.keyId ?? 0; const formData = new FormData(); - formData.set('keyid', key); + formData.set('keyid', key.toString()); const response = await fetch(CLAIM_URL, { method: 'POST',