Skip to content

Commit

Permalink
Fix #15 - Improve developer README for openstudioreleases (#17)
Browse files Browse the repository at this point in the history
* Fix #15 - Improve developer README for openstudioreleases

* Review comments  + clarify cors.json

* Update openstudioreleases/README.md

* Update openstudioreleases/README.md

* Update openstudioreleases/README.md

---------

Co-authored-by: Dan Macumber <dan.macumber@gmail.com>
  • Loading branch information
jmarrec and macumber authored Jan 13, 2025
1 parent d8e4c3c commit 7932c17
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 10 deletions.
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=
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 osc-downloads data stream.

## 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**

```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
# Set development or production

set `.env.prd` for production build
set `NODE_ENV` in the `.env` to either "development" or "production" before making a build

0 comments on commit 7932c17

Please sign in to comment.