diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index e0dc7351..a02e9900 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -2,15 +2,8 @@ name: Create docker images on: push: - branches: - - master - - main - # Publish semver tags as releases. - tags: [ 'v*.*.*' ] - pull_request: - branches: - - master - - main + tags: + - 'v*.*.*' workflow_dispatch: jobs: @@ -20,8 +13,6 @@ jobs: permissions: contents: read packages: write - # This is used to complete the identity challenge - # with sigstore/fulcio when running outside of PRs. id-token: write strategy: @@ -31,25 +22,22 @@ jobs: steps: - uses: actions/checkout@v5 - # Install the cosign tool except on PR - # https://github.com/sigstore/cosign-installer + # Install cosign (for image signing) - name: Install cosign - if: github.event_name != 'pull_request' uses: sigstore/cosign-installer@v3 - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 - - name: Log into registry docker.io - if: github.event_name != 'pull_request' && github.repository == 'umami-software/umami' + - name: Log into Docker Hub + if: github.repository == 'umami-software/umami' uses: docker/login-action@v3 with: registry: docker.io username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - - name: Log into ghcr registry - if: github.event_name != 'pull_request' + - name: Log into GHCR uses: docker/login-action@v3 with: registry: ghcr.io @@ -67,14 +55,8 @@ jobs: latest=auto prefix=${{ matrix.db-type }}- tags: | - type=ref,event=branch - type=ref,event=pr - - # output 1.1.2 type=semver,pattern={{version}} - # output 1.1 type=semver,pattern={{major}}.{{minor}} - # output 1 type=semver,pattern={{major}} - name: Build and push Docker image @@ -84,15 +66,14 @@ jobs: context: . platforms: linux/amd64,linux/arm64 build-args: DATABASE_TYPE=${{ matrix.db-type }} - push: ${{ github.event_name != 'pull_request' }} + push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} cache-from: type=gha cache-to: type=gha,mode=max - # Sign the resulting Docker image digest except on PRs. + # Sign the published image digest - name: Sign the published Docker image - if: ${{ github.event_name != 'pull_request' }} env: TAGS: ${{ steps.meta.outputs.tags }} DIGEST: ${{ steps.build-and-push.outputs.digest }} diff --git a/cypress/e2e/api-website.cy.ts b/cypress/e2e/api-website.cy.ts index 7f7d17c3..cd336bda 100644 --- a/cypress/e2e/api-website.cy.ts +++ b/cypress/e2e/api-website.cy.ts @@ -149,6 +149,21 @@ describe('Website API tests', () => { }); }); + it('Updates a website with only shareId.', () => { + cy.request({ + method: 'POST', + url: `/api/websites/${websiteId}`, + headers: { + 'Content-Type': 'application/json', + Authorization: Cypress.env('authorization'), + }, + body: { shareId: 'ABCDEF' }, + }).then(response => { + expect(response.status).to.eq(200); + expect(response.body).to.have.property('shareId', 'ABCDEF'); + }); + }); + it('Resets a website by removing all data related to the website.', () => { cy.request({ method: 'POST', diff --git a/src/lib/date.ts b/src/lib/date.ts index fa87277f..afbe0721 100644 --- a/src/lib/date.ts +++ b/src/lib/date.ts @@ -103,9 +103,18 @@ export const DATE_FORMATS = { year: 'yyyy', }; +const TIMEZONE_MAPPINGS: Record = { + 'Asia/Calcutta': 'Asia/Kolkata', +}; + +export function normalizeTimezone(timezone: string): string { + return TIMEZONE_MAPPINGS[timezone] || timezone; +} + export function isValidTimezone(timezone: string) { try { - Intl.DateTimeFormat(undefined, { timeZone: timezone }); + const normalizedTimezone = normalizeTimezone(timezone); + Intl.DateTimeFormat(undefined, { timeZone: normalizedTimezone }); return true; } catch { return false; diff --git a/src/lib/schema.ts b/src/lib/schema.ts index 965eae07..24ef99c3 100644 --- a/src/lib/schema.ts +++ b/src/lib/schema.ts @@ -1,10 +1,13 @@ import { z } from 'zod'; -import { isValidTimezone } from '@/lib/date'; +import { isValidTimezone, normalizeTimezone } from '@/lib/date'; import { UNIT_TYPES } from './constants'; -export const timezoneParam = z.string().refine(value => isValidTimezone(value), { - message: 'Invalid timezone', -}); +export const timezoneParam = z + .string() + .refine((value: string) => isValidTimezone(value), { + message: 'Invalid timezone', + }) + .transform((value: string) => normalizeTimezone(value)); export const unitParam = z.string().refine(value => UNIT_TYPES.includes(value), { message: 'Invalid unit',