Skip to content

Commit

Permalink
Merge 8e0fcb5 into 098a9f8
Browse files Browse the repository at this point in the history
  • Loading branch information
2fd committed Dec 8, 2022
2 parents 098a9f8 + 8e0fcb5 commit 4e4014a
Show file tree
Hide file tree
Showing 17 changed files with 161 additions and 167 deletions.
20 changes: 17 additions & 3 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,21 @@ jobs:
github_token: ${{ secrets.GITHUB_TOKEN }}

- name: testing
run: npm test -- --coverage
run: NODE_OPTIONS="--max-old-space-size=4096" npm test -- --coverage

- name: building
run: npm run build
- name: coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: setup envs
run: touch .env

- name: build image
id: build-image
uses: redhat-actions/buildah-build@v2
with:
image: events
tags: ${{ github.sha }}
dockerfiles: |
./Dockerfile
36 changes: 27 additions & 9 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:

release:
runs-on: ubuntu-20.04
outputs:
registry-path: ${{ steps.push-to-quay.outputs.registry-path }}
registry-paths: ${{ steps.push-to-quay.outputs.registry-paths }}

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -39,15 +42,15 @@ jobs:
run: source ./node_modules/.bin/setup-environment $PWD website-events-prd

- name: testing
run: npm test -- --coverage
run: NODE_OPTIONS="--max-old-space-size=2048" npm test -- --coverage

# - name: coveralls
# uses: coverallsapp/github-action@v1.1.2
# with:
# github-token: ${{ secrets.GITHUB_TOKEN }}
- name: coveralls
uses: coverallsapp/github-action@master
with:
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: export public env
run: env | grep GATSBY_ > .env
- name: setup envs
run: touch .env

- name: build image
id: build-image
Expand All @@ -68,5 +71,20 @@ jobs:
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_TOKEN }}

- name: print image url
run: echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
- name: Print image url
run: |
echo "Image pushed to ${{ steps.push-to-quay.outputs.registry-paths }}"
deployment:
needs: [build-push]
name: "Deploy to: dev"
runs-on: ubuntu-latest
steps:
- name: Trigger deployment
id: deploy
uses: decentraland/dcl-deploy-action@main
with:
dockerImage: "${{ needs.build-push.outputs.registry-path }}"
serviceName: events2
env: dev
token: ${{ secrets.GITHUB_TOKEN }}
2 changes: 2 additions & 0 deletions gatsby-browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import React from "react"
import "core-js/features/set-immediate"

import "./src/config"

// eslint-disable-next-line css-import-order/css-import-order
import "semantic-ui-css/semantic.min.css"
// eslint-disable-next-line css-import-order/css-import-order
Expand Down
27 changes: 9 additions & 18 deletions gatsby-ssr.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,15 @@ export function onPreRenderHTML(
})

const postBodyComponents = [...getPostBodyComponents()]

if (process.env.GATSBY_SEGMENT_KEY) {
postBodyComponents.push(
<Segment
key="segment"
analyticsKey={process.env.GATSBY_SEGMENT_KEY}
trackPage={false}
/>
)
} else {
console.warn("Missing GATSBY_SEGMENT_KEY environment")
}

if (process.env.GATSBY_ROLLBAR_TOKEN) {
postBodyComponents.push(<Rollbar key="rollbar" />)
} else {
console.warn("Missing GATSBY_ROLLBAR_TOKEN environment")
}
postBodyComponents.push(
<Segment
key="segment"
analyticsKey={process.env.GATSBY_SEGMENT_KEY}
trackPage={false}
/>
)

postBodyComponents.push(<Rollbar key="rollbar" />)

replaceHeadComponents(headComponents)
replacePostBodyComponents(postBodyComponents)
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"babel-jest": "^27.5.1",
"core-js": "^3.22.2",
"cssnano": "^5.0.10",
"decentraland-gatsby": "^5.47.0",
"decentraland-gatsby": "^5.51.0",
"es6-shim": "^0.35.6",
"express-fileupload": "^1.2.1",
"gatsby": "^4.1.2",
Expand Down
3 changes: 1 addition & 2 deletions src/api/Events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ export type EditSchedule = Pick<
>

export default class Events extends API {
static Url =
process.env.GATSBY_EVENTS_URL || `https://events.decentraland.org/api`
static Url = env("EVENTS_URL", `https://events.decentraland.org/api`)

static Cache = new Map<string, Events>()

Expand Down
10 changes: 10 additions & 0 deletions src/config/dev.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"GATSBY_CHAIN_ID": "1,137",
"GATSBY_DECENTRALAND_URL": "https://play.decentraland.org",
"GATSBY_EVENTS_URL": "/api",
"GATSBY_LAND_URL": "https://api.decentraland.org",
"GATSBY_PROFILE_URL": "https://peer.decentraland.org",
"GATSBY_ROLLBAR_TOKEN": "d4ef2affdfbe4816b98a0c7e31c90820",
"GATSBY_SEGMENT_KEY": "a4h4BC4dL1v7FhIQKKuPHEdZIiNRDVhc",
"GATSBY_WEB_PUSH,_KEY": "BDcSrhptgGRYliwF8EtHUjKS7zwUAb7xiKZn2wsGfqDpWhXld5844vAKzzX6X8OvmcjGEfuoHvnYVKoijpL1D_w"
}
9 changes: 9 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { setupEnv } from "decentraland-gatsby/dist/utils/env"

import dev from "./dev.json"
import prod from "./prod.json"
import stg from "./stg.json"

const envs = { dev, stg, prod }

setupEnv(envs)
10 changes: 10 additions & 0 deletions src/config/prod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"GATSBY_CHAIN_ID": "1,137",
"GATSBY_DECENTRALAND_URL": "https://play.decentraland.org",
"GATSBY_EVENTS_URL": "https://events.decentraland.org/api",
"GATSBY_LAND_URL": "https://api.decentraland.org",
"GATSBY_PROFILE_URL": "https://peer.decentraland.org",
"GATSBY_ROLLBAR_TOKEN": "d4ef2affdfbe4816b98a0c7e31c90820",
"GATSBY_SEGMENT_KEY": "d4skMcpfGrW2tP8FGTDtCIetsp3W7Boo",
"GATSBY_WEB_PUSH_KEY": "BDcSrhptgGRYliwF8EtHUjKS7zwUAb7xiKZn2wsGfqDpWhXld5844vAKzzX6X8OvmcjGEfuoHvnYVKoijpL1D_w"
}
1 change: 1 addition & 0 deletions src/config/stg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
12 changes: 5 additions & 7 deletions src/entities/Event/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Time from "decentraland-gatsby/dist/utils/date/Time"
import env from "decentraland-gatsby/dist/utils/env"
import padStart from "lodash/padStart"
import { RRule, Weekday } from "rrule"

Expand All @@ -15,15 +16,12 @@ import {
Weekdays,
} from "./types"

const DECENTRALAND_URL =
process.env.GATSBY_DECENTRALAND_URL ||
process.env.DECENTRALAND_URL ||
const DECENTRALAND_URL = env(
"DECENTRALAND_URL",
"https://play.decentraland.org"
)

const EVENTS_URL =
process.env.EVENTS_URL ||
process.env.GATSBY_EVENTS_URL ||
"https://events.decentraland.org/api"
const EVENTS_URL = env("EVENTS_URL", "https://events.decentraland.org/api")

export function siteUrl(pathname = "") {
const target = new URL(EVENTS_URL)
Expand Down
5 changes: 2 additions & 3 deletions src/hooks/usePushSubscription.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import useAsyncEffect from "decentraland-gatsby/dist/hooks/useAsyncEffect"
import usePatchState from "decentraland-gatsby/dist/hooks/usePatchState"
import env from "decentraland-gatsby/dist/utils/env"
import { fromWebPushKey } from "decentraland-gatsby/dist/utils/string/base64"

import useServiceWorker from "./useServiceWorker"
Expand All @@ -9,9 +10,7 @@ export type PushSubscriptionState = {
subscription: PushSubscription | null
}

const applicationServerKey = fromWebPushKey(
process.env.GATSBY_WEB_PUSH_KEY || ""
)
const applicationServerKey = fromWebPushKey(env("WEB_PUSH_KEY", ""))

export default function usePushSubscription(path = "/sw.js") {
const registration = useServiceWorker(path)
Expand Down
5 changes: 3 additions & 2 deletions src/modules/locations.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import API from "decentraland-gatsby/dist/utils/api/API"
import env from "decentraland-gatsby/dist/utils/env"

import { EventType } from "../entities/Event/types"
import {
Expand All @@ -8,7 +9,7 @@ import {
} from "../entities/Event/utils"
import { ALL_EVENT_CATEGORY } from "../entities/EventCategory/types"

const GATSBY_BASE_URL = process.env.GATSBY_BASE_URL || "/"
const BASE_URL = env("BASE_URL", "/")

export enum EventView {
Attendees = "attendees",
Expand Down Expand Up @@ -89,7 +90,7 @@ export function url(
path: string,
query?: Record<string, string> | URLSearchParams
) {
return API.url(GATSBY_BASE_URL, path, query)
return API.url(BASE_URL, path, query)
}

export default {
Expand Down
51 changes: 17 additions & 34 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useMemo, useState } from "react"
import React, { useEffect, useMemo, useState } from "react"

import { Helmet } from "react-helmet"

Expand All @@ -7,11 +7,9 @@ import useAuthContext from "decentraland-gatsby/dist/context/Auth/useAuthContext
import useAsyncMemo from "decentraland-gatsby/dist/hooks/useAsyncMemo"
import useFormatMessage from "decentraland-gatsby/dist/hooks/useFormatMessage"
import { navigate } from "decentraland-gatsby/dist/plugins/intl"
import prevent from "decentraland-gatsby/dist/utils/react/prevent"
import { Container } from "decentraland-ui/dist/components/Container/Container"

import { CarouselEvents } from "../components/Event/CarouselEvents/CarouselEvents"
import EventModal from "../components/Event/EventModal/EventModal"
import { ListEvents } from "../components/Event/ListEvents/ListEvents"
import { NoEvents } from "../components/Event/NoEvents/NoEvents"
import { TrendingEvents } from "../components/Event/TrendingEvents/TrendingEvents"
Expand Down Expand Up @@ -59,56 +57,41 @@ export default function IndexPage() {
const filters = useMemo(() => toEventFilters(params), [params])
const [enabledNotification, setEnabledNotification] = useState(false)

// redirect old urls to the new ones
useEffect(() => {
if (event) {
navigate(locations.event(event.id), { replace: true })
}
}, [event])

return (
<>
<Helmet>
<title>{event?.name || l("social.home.title") || ""}</title>
<meta
name="description"
content={event?.description || l("social.home.description") || ""}
/>
<title>{l("social.home.title") || ""}</title>
<meta name="description" content={l("social.home.description") || ""} />

<meta
property="og:title"
content={event?.name || l("social.home.title") || ""}
/>
<meta property="og:title" content={l("social.home.title") || ""} />
<meta
property="og:description"
content={event?.description || l("social.home.description") || ""}
/>
<meta
property="og:image"
content={event?.image || l("social.home.image") || ""}
content={l("social.home.description") || ""}
/>
<meta property="og:image" content={l("social.home.image") || ""} />
<meta property="og:site" content={l("social.home.site") || ""} />

<meta
name="twitter:title"
content={event?.description || l("social.home.title") || ""}
/>
<meta name="twitter:title" content={l("social.home.title") || ""} />
<meta
name="twitter:description"
content={event?.description || l("social.home.description") || ""}
/>
<meta
name="twitter:image"
content={event?.image || l("social.home.image") || ""}
/>
<meta
name="twitter:card"
content={event ? "summary_large_image" : l("social.home.card") || ""}
content={l("social.home.description") || ""}
/>
<meta name="twitter:image" content={l("social.home.image") || ""} />
<meta name="twitter:card" content={l("social.home.card") || ""} />
<meta name="twitter:creator" content={l("social.home.creator") || ""} />
<meta name="twitter:site" content={l("social.home.site") || ""} />
</Helmet>
<EnabledNotificationModal
open={enabledNotification}
onClose={() => setEnabledNotification(false)}
/>
<EventModal
event={event}
onClose={prevent(() => navigate(locations.events()))}
/>

<Navigation activeTab={NavigationTab.Events} search />

Expand Down
Loading

0 comments on commit 4e4014a

Please sign in to comment.