From 31978e2b7369ec05b29443d8bbb9825855c57457 Mon Sep 17 00:00:00 2001 From: Tommaso Bailetti Date: Mon, 23 Oct 2023 09:25:23 +0200 Subject: [PATCH] ci-cd --- .github/workflows/build.yml | 21 +++++++++++++++++++++ .github/workflows/linters.yml | 28 ++++++++++++++++++++++++++++ .vscode/extensions.json | 8 -------- Containerfile | 4 ++-- build.sh | 0 dev.sh | 18 ++++++++++++++---- src/assets/main.css | 2 +- 7 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/build.yml create mode 100644 .github/workflows/linters.yml delete mode 100644 .vscode/extensions.json mode change 100644 => 100755 build.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..b963692 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,21 @@ +name: Build + +on: + push: + pull_request: + workflow_dispatch: + +jobs: + ui: + name: UI + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - run: | + ./build.sh + - name: Upload artifact + uses: actions/upload-artifact@v3 + with: + name: dist-${{ github.sha }} + path: dist + retention-days: 7 diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml new file mode 100644 index 0000000..7e82c36 --- /dev/null +++ b/.github/workflows/linters.yml @@ -0,0 +1,28 @@ +name: Linters + +on: + pull_request: + workflow_dispatch: + +jobs: + prettier: + name: Prettier + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-setup@v1 + - name: Run prettier + run: | + ./dev.sh npm ci + ./dev.sh npm run format | reviewdog -f=diff -reporter=github-pr-check + + eslint: + name: Eslint + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - uses: reviewdog/action-setup@v1 + - name: Run eslint + run: | + ./dev.sh npm ci + ./dev.sh npm run lint:check -- -f checkstyle | reviewdog -f=checkstyle -reporter=github-pr-check diff --git a/.vscode/extensions.json b/.vscode/extensions.json deleted file mode 100644 index 009a534..0000000 --- a/.vscode/extensions.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "recommendations": [ - "Vue.volar", - "Vue.vscode-typescript-vue-plugin", - "dbaeumer.vscode-eslint", - "esbenp.prettier-vscode" - ] -} diff --git a/Containerfile b/Containerfile index ce261fc..fe5679c 100644 --- a/Containerfile +++ b/Containerfile @@ -11,14 +11,14 @@ COPY package-lock.json . RUN npm ci COPY public public COPY src src +COPY .postcssrc.json . COPY env.d.ts . COPY index.html . +COPY tailwind.config.ts . COPY tsconfig.app.json . COPY tsconfig.json . COPY tsconfig.node.json . -COPY tsconfig.vitest.json . COPY vite.config.ts . -COPY vitest.config.ts . RUN npm run build FROM docker.io/nginx:stable-alpine-slim as prod diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 diff --git a/dev.sh b/dev.sh index ef03ac1..a7005db 100755 --- a/dev.sh +++ b/dev.sh @@ -9,18 +9,28 @@ build_image() { podman build \ --force-rm \ --layers \ - --target dev \ - --tag "${dev_image}" \ + --target "$1" \ + --tag "$2" \ . } if [ "$1" = "build" ]; then - build_image + build_image "dev" "$dev_image" exit 0 fi +if [ "$1" = "prod" ]; then + build_image "prod" "$dev_image:prod" + podman run \ + --rm \ + --publish 8080:80 \ + "$dev_image:prod" + exit 0 +fi + + if ! podman image exists "$dev_image"; then - build_image + build_image "dev" "$dev_image" fi # params given will be appended at the end of the command diff --git a/src/assets/main.css b/src/assets/main.css index bd6213e..b5c61c9 100644 --- a/src/assets/main.css +++ b/src/assets/main.css @@ -1,3 +1,3 @@ @tailwind base; @tailwind components; -@tailwind utilities; \ No newline at end of file +@tailwind utilities;