From ef99a6830338355dceec4420ce4113aad52debcf Mon Sep 17 00:00:00 2001 From: Samuel Therrien Date: Wed, 4 Dec 2024 14:39:18 -0500 Subject: [PATCH 1/5] Manual deployments and add git tags --- .github/workflows/canopeum_backend_deploy.yml | 15 +++++++++++---- .github/workflows/canopeum_frontend_deploy.yml | 15 +++++++++++---- 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/.github/workflows/canopeum_backend_deploy.yml b/.github/workflows/canopeum_backend_deploy.yml index a3b37e4ac..0286c8ce9 100644 --- a/.github/workflows/canopeum_backend_deploy.yml +++ b/.github/workflows/canopeum_backend_deploy.yml @@ -1,6 +1,7 @@ name: canopeum_backend_deploy on: + workflow_dispatch: # Allows manual builds push: branches: - production @@ -18,12 +19,14 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 - - name: 'login' - uses: docker/login-action@v1 + - uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Get datetime + id: datetime + run: echo DATETIME=$(date +'%Y-%m-%d-%H-%M') >> $GITHUB_OUTPUT - name: Publish Docker image id: push uses: docker/build-push-action@v3 @@ -31,5 +34,9 @@ jobs: context: ./canopeum_backend file: canopeum_backend/Dockerfile push: true - tags: ghcr.io/beslogic/canopeum_backend:latest - labels: latest + tags: ghcr.io/beslogic/canopeum_backend:latest,ghcr.io/beslogic/canopeum_backend:${{steps.datetime.outputs.DATETIME}} + - name: Create and push git tag + continue-on-error: true + run: | + git tag ${{steps.datetime.outputs.DATETIME}} + git push origin --tags diff --git a/.github/workflows/canopeum_frontend_deploy.yml b/.github/workflows/canopeum_frontend_deploy.yml index ae929918b..ab45b3764 100644 --- a/.github/workflows/canopeum_frontend_deploy.yml +++ b/.github/workflows/canopeum_frontend_deploy.yml @@ -1,6 +1,7 @@ name: canopeum_frontend_deploy on: + workflow_dispatch: # Allows manual builds push: branches: - production @@ -21,12 +22,14 @@ jobs: run: npm ci - name: Build project run: npm run build - - name: 'login' - uses: docker/login-action@v1 + - uses: docker/login-action@v1 with: registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - name: Get datetime + id: datetime + run: echo DATETIME=$(date +'%Y-%m-%d-%H-%M') >> $GITHUB_OUTPUT - name: Publish Docker image id: push uses: docker/build-push-action@v3 @@ -34,5 +37,9 @@ jobs: context: ./canopeum_frontend file: canopeum_frontend/Dockerfile push: true - tags: ghcr.io/beslogic/canopeum_frontend:latest - labels: latest + tags: ghcr.io/beslogic/canopeum_frontend:latest,ghcr.io/beslogic/canopeum_frontend:${{steps.datetime.outputs.DATETIME}} + - name: Create and push git tag + continue-on-error: true + run: | + git tag ${{steps.datetime.outputs.DATETIME}} + git push origin --tags From a9aa1a5f549659400019819a128aa846d8ba3cfe Mon Sep 17 00:00:00 2001 From: Samuel Therrien Date: Wed, 4 Dec 2024 15:23:46 -0500 Subject: [PATCH 2/5] Add a VITE_BUILD_DATE to be able to differentiate builds --- canopeum_frontend/src/App.tsx | 3 +++ canopeum_frontend/src/vite-env.d.ts | 1 + canopeum_frontend/vite.config.ts | 3 +++ 3 files changed, 7 insertions(+) diff --git a/canopeum_frontend/src/App.tsx b/canopeum_frontend/src/App.tsx index 86a96e3bb..ca73e5890 100644 --- a/canopeum_frontend/src/App.tsx +++ b/canopeum_frontend/src/App.tsx @@ -10,6 +10,9 @@ import muiCustomTheme from '@assets/styles/muiCustomTheme' import LanguageContextProvider from '@components/context/LanguageContext' import SnackbarContextProvider from '@components/context/SnackbarContext' +console.info({ VITE_BUILD_DATE }) +// const { VITE_BUILD_DATE, BUILD_DATE } = import.meta.env +console.info({ VITE_BUILD_DATE }) const App = () => ( diff --git a/canopeum_frontend/src/vite-env.d.ts b/canopeum_frontend/src/vite-env.d.ts index 11f02fe2a..4f684e41a 100644 --- a/canopeum_frontend/src/vite-env.d.ts +++ b/canopeum_frontend/src/vite-env.d.ts @@ -1 +1,2 @@ /// +declare const VITE_BUILD_DATE: Date diff --git a/canopeum_frontend/vite.config.ts b/canopeum_frontend/vite.config.ts index 0ec9641c4..ce39ef795 100644 --- a/canopeum_frontend/vite.config.ts +++ b/canopeum_frontend/vite.config.ts @@ -27,5 +27,8 @@ export default ({ mode }: { mode: string }) => { usePolling: true, }, }, + define: { + VITE_BUILD_DATE: new Date(), + }, }) } From b73c610ea5ccc3dd97c2e833b98be168c043dd21 Mon Sep 17 00:00:00 2001 From: Samuel Therrien Date: Wed, 4 Dec 2024 15:31:08 -0500 Subject: [PATCH 3/5] Remove accidental duplicated print --- canopeum_frontend/src/App.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/canopeum_frontend/src/App.tsx b/canopeum_frontend/src/App.tsx index ca73e5890..981982e86 100644 --- a/canopeum_frontend/src/App.tsx +++ b/canopeum_frontend/src/App.tsx @@ -11,8 +11,7 @@ import LanguageContextProvider from '@components/context/LanguageContext' import SnackbarContextProvider from '@components/context/SnackbarContext' console.info({ VITE_BUILD_DATE }) -// const { VITE_BUILD_DATE, BUILD_DATE } = import.meta.env -console.info({ VITE_BUILD_DATE }) + const App = () => ( From a551792fe20a7c4e270aff8170fb514eca6a5c99 Mon Sep 17 00:00:00 2001 From: Samuel Therrien Date: Wed, 4 Dec 2024 15:36:36 -0500 Subject: [PATCH 4/5] Bump docker/login-action@v3 and docker/build-push-action@v6 --- .github/workflows/canopeum_backend_deploy.yml | 4 ++-- .github/workflows/canopeum_frontend_deploy.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/canopeum_backend_deploy.yml b/.github/workflows/canopeum_backend_deploy.yml index 0286c8ce9..1e1567b4f 100644 --- a/.github/workflows/canopeum_backend_deploy.yml +++ b/.github/workflows/canopeum_backend_deploy.yml @@ -19,7 +19,7 @@ jobs: fail-fast: false steps: - uses: actions/checkout@v4 - - uses: docker/login-action@v1 + - uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -29,7 +29,7 @@ jobs: run: echo DATETIME=$(date +'%Y-%m-%d-%H-%M') >> $GITHUB_OUTPUT - name: Publish Docker image id: push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: context: ./canopeum_backend file: canopeum_backend/Dockerfile diff --git a/.github/workflows/canopeum_frontend_deploy.yml b/.github/workflows/canopeum_frontend_deploy.yml index ab45b3764..ef821d8df 100644 --- a/.github/workflows/canopeum_frontend_deploy.yml +++ b/.github/workflows/canopeum_frontend_deploy.yml @@ -22,7 +22,7 @@ jobs: run: npm ci - name: Build project run: npm run build - - uses: docker/login-action@v1 + - uses: docker/login-action@v3 with: registry: ghcr.io username: ${{ github.actor }} @@ -32,7 +32,7 @@ jobs: run: echo DATETIME=$(date +'%Y-%m-%d-%H-%M') >> $GITHUB_OUTPUT - name: Publish Docker image id: push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v6 with: context: ./canopeum_frontend file: canopeum_frontend/Dockerfile From c281f84e3568aa8d9bef055d28e13ed7ec4c3af9 Mon Sep 17 00:00:00 2001 From: "Samuel T." Date: Wed, 4 Dec 2024 16:47:53 -0500 Subject: [PATCH 5/5] fix map use location zoom (#323) --- canopeum_frontend/src/pages/MapPage.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/canopeum_frontend/src/pages/MapPage.tsx b/canopeum_frontend/src/pages/MapPage.tsx index 15a421eae..50c3d8d82 100644 --- a/canopeum_frontend/src/pages/MapPage.tsx +++ b/canopeum_frontend/src/pages/MapPage.tsx @@ -14,7 +14,7 @@ import { getSiteTypeIconKey, type SiteTypeID } from '@models/SiteType' import type { SiteMap } from '@services/api' import { getApiBaseUrl } from '@services/apiSettings' -const PIN_FOCUS_ZOOM_LEVEL = 15 +const PIN_FOCUS_ZOOM_LEVEL = 12 const MAP_DISTANCE_ZOOM_MULTIPLIER = 20 /** @@ -131,7 +131,11 @@ const MapPage = () => { initialMapState = defaultMapLocation(fetchedSites) } else { // Otherwise focus on the user's position - initialMapState = position.coords + // NOTE: Can't spread or clone a GeolocationPosition ! + initialMapState = { + longitude: position.coords.longitude, + latitude: position.coords.latitude, + } } setMapViewState(mvs => ({ ...mvs, ...initialMapState })) }), [fetchData, searchParams]) @@ -153,8 +157,11 @@ const MapPage = () => { {sites.map(site => { - const latitude = Number(site.coordinate.ddLatitude) - const longitude = Number(site.coordinate.ddLongitude) + const latitude = site.coordinate.ddLatitude + const longitude = site.coordinate.ddLongitude + + // Unset or invalid coordinate should be ignored from map pins + if (!latitude || !longitude) return return ( { ) - })} + }).filter(Boolean)}