Adds deploy method
Some checks failed
/ build (push) Failing after 1s

This commit is contained in:
Michel 2024-11-07 18:28:45 +01:00
parent d0c56d5d76
commit 59e639eed6
3 changed files with 37 additions and 7 deletions

View file

@ -6,7 +6,23 @@ jobs:
build: build:
runs-on: runs-on:
- kiljho - kiljho
- self-hosted
steps: steps:
- name: Test direct issue - name: Update Service
run: /home/michel/hello.sh 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"

14
deploy/deploy.sh Normal file
View file

@ -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

View file

@ -95,7 +95,7 @@ async function renderDetails(childRow: HTMLDivElement, gameid: number) {
childRow.removeChild(loadingContainer); childRow.removeChild(loadingContainer);
const parser = new DOMParser(); const parser = new DOMParser();
const gameDisplay: HTMLDivElement|null = parser.parseFromString(getDetailsHTML(gameData), 'text/html').body.firstChild; const gameDisplay: HTMLDivElement|null = <HTMLDivElement|null>(parser.parseFromString(getDetailsHTML(gameData), 'text/html').body.firstChild);
if (!gameDisplay) { if (!gameDisplay) {
return; return;
@ -103,10 +103,10 @@ async function renderDetails(childRow: HTMLDivElement, gameid: number) {
gameDisplay.querySelectorAll('.claim-btn').forEach(btn => { gameDisplay.querySelectorAll('.claim-btn').forEach(btn => {
btn.addEventListener('click', async () => { btn.addEventListener('click', async () => {
const key = btn.closest('.key')?.dataset.keyId ?? 0; const key = btn.closest<HTMLDivElement>('.key')?.dataset.keyId ?? 0;
const formData = new FormData(); const formData = new FormData();
formData.set('keyid', key); formData.set('keyid', key.toString());
const response = await fetch(CLAIM_URL, { const response = await fetch(CLAIM_URL, {
method: 'POST', method: 'POST',