Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #15 - Improve developer README for openstudioreleases #17

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion openstudioreleases/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ FIREBASE_PROJECT_ID=
FIREBASE_STORAGE_BUCKET=
FIREBASE_MESSAGING_SENDER_ID=
FIREBASE_APP_ID=
FIREBASE_MEASUREMENT_ID=
FIREBASE_MEASUREMENT_ID=
GA_ID=
Copy link
Collaborator

@macumber macumber Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have a GA_ID in the .env file, I think you just enter FIREBASE_MEASUREMENT_ID and that links to Google Analytics

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ cd openstudioreleases && rg GA_ID
src/index.tsx
15:if (config.GA_ID) {
16:  ReactGA.initialize(config.GA_ID);

src/config.tsx
2:  GA_ID: process.env.GA_ID,

src/ga/usePageView.tsx
15:    if (!process.env.GA_ID) 

82 changes: 73 additions & 9 deletions openstudioreleases/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,48 @@
# OpenStudioCoalition GitHub IO Release Pages

## Install Yarn and package dependencies

Install the `yarn` package manager. Assuming you have installed nodejs and npm, `npm install -g yarn`

Now install the dependencies:

```shell
yarn install
```

## Setup secrets

### Download Firebase config file

Go to [OSC Downloads](https://console.firebase.google.com/u/2/project/osc-downloads/overview), you can access this with the OSC email.

https://support.google.com/firebase/answer/7015592?hl=en#zippy=%2Cin-this-article

Go to the OSC Downloads's Settings, get values from the osc "Config" snippet and place it at `firebase-config.json` next to this readme, changing the format to be a JSON one:

```json
{
"apiKey": "XXXXX",
"authDomain": "XXXXX",
"projectId": "osc-downloads",
"storageBucket": "XXXXX",
"messagingSenderId": "XXXXX",
"appId": "XXXXX",
"measurementId": "XXXXX"
}
```

Additionally, do `cp .env.example .env`

Then edit it to add the values to each key.

### Google Analytics

Set the `GA_ID` in the `.env` file. This is the Measurement ID for the OS App website itself (OS App Git - GA4)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@macumber I am not sure at all this is right. #15 (comment)


## Running the website
Run dev mode

```bash
yarn dev
```
Expand All @@ -11,15 +53,33 @@ Build
yarn build
```

### Too many open files error

*Note:* if you get this error: `Error: EMFILE: too many open files, watch 'path/to/openstudiocoalition.github.io/openstudioreleases/public'`

On ubuntu 24.04, I modified `/etc/sysctl.conf`, added

```
# Default: 128
fs.inotify.max_user_instances = 512
# Default: 65536
fs.inotify.max_user_watches = 524288
```

Reloaded: `sudo sysctl --system`


## Update release assets

This will parse the Github Releases and save a JSON at `src/releases/releases.json`

```bash
yarn es scripts/getReleaseInfo.ts
```

## Firebase

[Test Project](https://console.firebase.google.com/u/2/project/osc-downloads/overview)
[OSC Downloads](https://console.firebase.google.com/u/2/project/osc-downloads/overview)

### Firebase Auth

Expand All @@ -37,7 +97,7 @@ This is the firestore rule to let the logged user to modify their own data.

This is needed for firstName, lastName, company, occupation, country

```yaml
```javascript
rules_version = '2';

service cloud.firestore {
Expand All @@ -53,7 +113,13 @@ service cloud.firestore {

The data is stored in the `users` collection.

The script below will get all users from the database and save to a json file
The script below will get all users from the database and save to a json file.

For it to work, you need the `firebase-service-account.json` with the private key next to this README.md (Ask the maintainers).

To generate one you will need to go to the [Firebase project Service Accounts settings](https://console.firebase.google.com/u/0/project/osc-downloads/settings/serviceaccounts/adminsdk)

Generate a new private key, and save it to `firebase-service-account.json`. **Note: as soon as you generate a new private key, the old key will stop working, so ask the maintainers to provide it instead**
Comment on lines +118 to +122
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@macumber please review this carefully... (also, do you have that json file to share with me?)


```bash
yarn es scripts/getUsers.ts
Expand All @@ -67,7 +133,7 @@ Modify the [rules](https://console.firebase.google.com/u/2/project/osc-downloads

This is the rule to enable any logged user to download the release assets

```yaml
```javascript
rules_version = '2';

service firebase.storage {
Expand All @@ -93,7 +159,7 @@ exec -l $SHELL
gcloud init
```

Upload `cors.json` to the bucket
Upload `./config/cors.json` to the bucket

```bash
gcloud storage buckets update gs://osc-downloads.appspot.com --cors-file=cors.json
Expand All @@ -106,8 +172,6 @@ yarn es scripts/getReleaseInfo.ts
yarn es scripts/syncReleaseAssets.ts
```

## Google Analytics

Set the `GA_ID` in the `.env` file
# TODO: explain this
jmarrec marked this conversation as resolved.
Show resolved Hide resolved

set `.env.prd` for production build
set `.env.prd` for production build