From 70f2987f76610f7ef1e2f03af958b55caca446e7 Mon Sep 17 00:00:00 2001 From: ukorvl Date: Mon, 24 Jun 2024 12:56:47 +0400 Subject: [PATCH] minor deploy and workflow changes #11 --- .github/actions/build/action.yml | 9 +++++ .github/actions/deploy/action.yml | 19 ++++++++++ .../actions/install-dependencies/action.yml | 0 .../{workflows => }/actions/test/action.yml | 9 +++-- .github/workflows/actions/build/action.yml | 21 ---------- .github/workflows/build.yml | 8 +++- .github/workflows/deploy.yml | 18 +++------ app/env.mjs | 4 +- app/manifest.ts | 38 +++++++++++++++++++ app/metadata.ts | 1 - public/manifest.json | 30 --------------- 11 files changed, 87 insertions(+), 70 deletions(-) create mode 100644 .github/actions/build/action.yml create mode 100644 .github/actions/deploy/action.yml rename .github/{workflows => }/actions/install-dependencies/action.yml (100%) rename .github/{workflows => }/actions/test/action.yml (73%) delete mode 100644 .github/workflows/actions/build/action.yml create mode 100644 app/manifest.ts delete mode 100644 public/manifest.json diff --git a/.github/actions/build/action.yml b/.github/actions/build/action.yml new file mode 100644 index 0000000..12255ea --- /dev/null +++ b/.github/actions/build/action.yml @@ -0,0 +1,9 @@ +name: "Build" +description: "Build the project." + +runs: + using: "composite" + steps: + - name: Build + shell: bash + run: npm run build diff --git a/.github/actions/deploy/action.yml b/.github/actions/deploy/action.yml new file mode 100644 index 0000000..6853b8f --- /dev/null +++ b/.github/actions/deploy/action.yml @@ -0,0 +1,19 @@ +name: 'Deploy' +description: 'Deploy the project.' + +runs: + using: 'composite' + steps: + - name: No jekyll + run: touch out/.nojekyll + - name: Deploy + uses: JamesIves/github-pages-deploy-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + branch: gh-pages + folder: out + clean: true + target-folder: . + git-config-name: ${{ github.actor }} + git-config-email: ${{ github.actor }}@users.noreply.github.com + commit-message: Deploy from commit ${{ github.sha }} diff --git a/.github/workflows/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml similarity index 100% rename from .github/workflows/actions/install-dependencies/action.yml rename to .github/actions/install-dependencies/action.yml diff --git a/.github/workflows/actions/test/action.yml b/.github/actions/test/action.yml similarity index 73% rename from .github/workflows/actions/test/action.yml rename to .github/actions/test/action.yml index ee9694b..f2909e8 100644 --- a/.github/workflows/actions/test/action.yml +++ b/.github/actions/test/action.yml @@ -1,14 +1,16 @@ -name: "Test" -description: "Lint and test the project." +name: 'Test' +description: 'Lint and test the project.' runs: - using: "composite" + using: 'composite' steps: - name: Lint + shell: bash run: | npm run lint npm run lint:editorconfig - name: Prettier rules check + shell: bash run: npm run prettier-check - name: e2e uses: cypress-io/github-action@v5 @@ -17,4 +19,5 @@ runs: start: npm start record: false - name: Check seo + shell: bash run: npm run check-seo diff --git a/.github/workflows/actions/build/action.yml b/.github/workflows/actions/build/action.yml deleted file mode 100644 index af15de3..0000000 --- a/.github/workflows/actions/build/action.yml +++ /dev/null @@ -1,21 +0,0 @@ -name: "Build" -description: "Build the project." - -inputs: - assets_path: - type: string - description: 'Path to load static assets' - required: false - default: '' - -runs: - using: "composite" - env: - GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }} - FORMSPREE_ID: ${{ secrets.FORMSPREE_ID }} - HOTJAR_ID: ${{ secrets.HOTJAR_ID }} - HOTJAR_SNIPPET_VERSION: ${{ secrets.HOTJAR_SNIPPET_VERSION }} - ASSETS_BASE_PATH: /s - steps: - - name: Build - run: npm run build diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 88468dd..1aa6cc5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -10,8 +10,13 @@ concurrency: jobs: build: - name: Build + name: Build on Node.js ${{ matrix.version }} runs-on: ubuntu-latest + env: + GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }} + FORMSPREE_ID: ${{ secrets.FORMSPREE_ID }} + HOTJAR_ID: ${{ secrets.HOTJAR_ID }} + HOTJAR_SNIPPET_VERSION: ${{ secrets.HOTJAR_SNIPPET_VERSION }} strategy: matrix: version: [18, 20, 22] @@ -26,4 +31,3 @@ jobs: uses: ./.github/actions/test - name: Build uses: ./.github/actions/build - diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 89d8fbd..a4668ce 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -19,6 +19,11 @@ jobs: deploy: name: Deploy runs-on: ubuntu-latest + env: + GA_TRACKING_ID: ${{ secrets.GA_TRACKING_ID }} + FORMSPREE_ID: ${{ secrets.FORMSPREE_ID }} + HOTJAR_ID: ${{ secrets.HOTJAR_ID }} + HOTJAR_SNIPPET_VERSION: ${{ secrets.HOTJAR_SNIPPET_VERSION }} steps: - name: Clone repository uses: actions/checkout@v4 @@ -28,16 +33,5 @@ jobs: node_version: 18 - name: Build uses: ./.github/actions/build - with: - assets_path: 'assets' - name: Deploy - uses: JamesIves/github-pages-deploy-action@v4 - with: - token: ${{ secrets.GITHUB_TOKEN }} - branch: gh-pages - folder: out - clean: true - target-folder: . - git-config-name: ${{ github.actor }} - git-config-email: ${{ github.actor }}@users.noreply.github.com - commit-message: Deploy from commit ${{ github.sha }} + uses: ./.github/actions/deploy diff --git a/app/env.mjs b/app/env.mjs index d53d70b..99366d5 100644 --- a/app/env.mjs +++ b/app/env.mjs @@ -1,5 +1,5 @@ import {createEnv} from '@t3-oss/env-nextjs'; -import {z} from 'zod'; +import {any, z} from 'zod'; /** * Checks if a string is not empty. @@ -35,6 +35,7 @@ const server = { CONTACT_PHONE: notEmptyString, LOCATION_GOOGLE_MAPS_LINK: notEmptyString.url(), LOCATION_ADDRESS_TEXT: notEmptyString, + ASSETS_BASE_PATH: any(), }; const client = {}; @@ -62,5 +63,6 @@ export const env = createEnv({ CONTACT_PHONE: process.env.CONTACT_PHONE, LOCATION_GOOGLE_MAPS_LINK: process.env.LOCATION_GOOGLE_MAPS_LINK, LOCATION_ADDRESS_TEXT: process.env.LOCATION_ADDRESS_TEXT, + ASSETS_BASE_PATH: process.env.ASSETS_BASE_PATH, }, }); diff --git a/app/manifest.ts b/app/manifest.ts new file mode 100644 index 0000000..3204bec --- /dev/null +++ b/app/manifest.ts @@ -0,0 +1,38 @@ +import {MetadataRoute} from 'next'; +import tailwindConfig from '../tailwind.config'; + +const colors = tailwindConfig.theme.extend.colors; +const {alternate = 'black'} = colors; + +// eslint-disable-next-line jsdoc/require-jsdoc +export default function manifest(): MetadataRoute.Manifest { + return { + name: 'Salsaviva - Salsa, Bachata and Kizomba in Yerevan', + short_name: 'Salsaviva', + description: 'Social dance school in Yerevan', + theme_color: alternate, + background_color: alternate, + display: 'standalone', + orientation: 'portrait', + scope: '/', + start_url: '/', + icons: [ + { + src: '/icons/logo_192.png', + type: 'image/png', + sizes: '192x192', + }, + { + src: '/icons/logo_maskable_192.png', + type: 'image/png', + sizes: '192x192', + purpose: 'maskable', + }, + { + src: '/icons/logo_512.png', + type: 'image/png', + sizes: '512x512', + }, + ], + }; +} diff --git a/app/metadata.ts b/app/metadata.ts index 1c6d103..073cc46 100644 --- a/app/metadata.ts +++ b/app/metadata.ts @@ -24,7 +24,6 @@ const metadata: Metadata = { 'social dance', ], authors: [{name: 'Ukorvl', url: 'https://github.com/ukorvl'}], - manifest: '/manifest.json', metadataBase: new URL(origin), openGraph: { title: 'Salsaviva', diff --git a/public/manifest.json b/public/manifest.json deleted file mode 100644 index 04b2157..0000000 --- a/public/manifest.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "name": "Salsaviva - Salsa, Bachata and Kizomba in Yerevan", - "short_name": "Salsaviva", - "description": "Social dance school in Yerevan", - "theme_color": "#18132d", - "background_color": "#18132d", - "display": "standalone", - "orientation": "portrait", - "scope": "/", - "start_url": "/", - "icons": [ - { - "src": "/icons/logo_192.png", - "type": "image/png", - "sizes": "192x192" - }, - { - "src": "/icons/logo_maskable.png", - "type": "image/png", - "sizes": "192x192", - "purpose": "maskable" - }, - { - "src": "/icons/logo_512.png", - "type": "image/png", - "sizes": "512x512" - } - ], - "splash_pages": null -}