Added version information in settings page & testing github actions

This commit is contained in:
Aleksi Lassila
2023-08-11 14:38:00 +03:00
parent 0b2bdedf86
commit 529ca0ef59
6 changed files with 91 additions and 3 deletions

64
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,64 @@
name: Build & Deploy
on:
push:
tags:
- v*
# branches:
# - master
# - dev
# pull_request:
# branches:
# - main
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
TAG: ${{ github.ref_name }}
jobs:
# test:
# timeout-minutes: 10
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v1
# # - name: Build containers
# # run: docker compose build
# - name: Test backend
# run: docker compose run --build backend sh -c 'npx prisma migrate reset --force && export NODE_ENV=test && npx jest'
push:
timeout-minutes: 10
runs-on: ubuntu-latest
# needs: test
# if: github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: 'Login to GitHub Container Registry'
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{github.actor}}
password: ${{secrets.GITHUB_TOKEN}}
- name: Build containers
run: docker compose -f docker-compose.yml -f docker-compose.prod.yml build
- name: Add tag
run: docker tag ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{env.TAG}}
# - name: Tag with Git SHA
# run: docker tag ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{github.sha}}
- name: Push to Docker Hub
run: |
docker push ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:${{env.TAG}}
docker push ${{env.REGISTRY}}/${{env.IMAGE_NAME}}:latest

View File

@@ -26,7 +26,7 @@ COPY package-lock.json .
RUN npm ci --omit dev
CMD [ "PORT", "9494", "node", "build" ]
CMD [ "npm", "run", "deply" ]
FROM node:18 as development

View File

@@ -1,10 +1,15 @@
{
"name": "reiverr",
"version": "0.1.0",
"repository": {
"type": "git",
"url": "https://github.com/aleksilassila/reiverr"
},
"scripts": {
"dev": "vite dev --host",
"build": "vite build",
"preview": "vite preview",
"deploy": "PORT=9494 node build/",
"test": "playwright test",
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",

View File

@@ -1,10 +1,15 @@
<script>
import { version } from '$app/environment';
</script>
<div class="h-screen flex flex-col items-center justify-center text-zinc-500">
<div class="flex-1 flex items-center justify-center max-w-xl text-center m-8">
This is the settings page. It's quite empty here. If you'd like to help populate it, or any
other part of the project, head over to the project GitHub page.
</div>
<div class="flex items-center p-8">
<div class="flex items-center p-8 gap-8">
<a href="https://github.com/aleksilassila/reiverr">GitHub</a>
<div>v{version}</div>
</div>
</div>

View File

@@ -1,5 +1,11 @@
import adapter from '@sveltejs/adapter-node';
import { vitePreprocess } from '@sveltejs/kit/vite';
import { readFileSync } from 'fs';
import { fileURLToPath } from 'url';
const file = fileURLToPath(new URL('package.json', import.meta.url));
const json = readFileSync(file, 'utf8');
const pkg = JSON.parse(json);
/** @type {import('@sveltejs/kit').Config} */
const config = {
@@ -11,7 +17,11 @@ const config = {
// adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list.
// If your environment is not supported or you settled on a specific environment, switch out the adapter.
// See https://kit.svelte.dev/docs/adapters for more information about adapters.
adapter: adapter()
adapter: adapter(),
version: {
name: pkg.version
}
},
vitePlugin: {

View File

@@ -1,8 +1,12 @@
import { sveltekit } from '@sveltejs/kit/vite';
import { defineConfig } from 'vitest/config';
// import * as pkg from './package.json';
export default defineConfig({
plugins: [sveltekit()],
// define: {
// PKG: pkg
// },
test: {
include: ['src/**/*.{test,spec}.{js,ts}']
}