Skip to content

Commit

Permalink
add github actions to deploy realtime and preview deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
aabassiouni committed May 19, 2024
1 parent 08b91c1 commit 17ec130
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 2 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/realtime-deploy-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy realtime - preview

on:
workflow_dispatch:
push:
branches:
- dev
paths:
- "apps/realtime/**"

jobs:
deploy:
name: Deploy realtime
runs-on: ubuntu-latest
environment: Preview
concurrency: deploy-group
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: cd ./apps/realtime
- run: flyctl deploy --remote-only -c ./fly.preview.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/realtime-deploy-production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy realtime - production

on:
workflow_dispatch:
push:
branches:
- main
paths:
- "apps/realtime/**"

jobs:
deploy:
name: Deploy realtime
runs-on: ubuntu-latest
environment: Production
concurrency: deploy-group
steps:
- uses: actions/checkout@v4
- uses: superfly/flyctl-actions/setup-flyctl@master
- run: cd ./apps/realtime
- run: flyctl deploy --remote-only -c ./fly.production.toml
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
25 changes: 25 additions & 0 deletions apps/realtime/fly.preview.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# fly.toml app configuration file generated for entrybase-realtime-preview on 2024-05-20T01:15:43+03:00
#
# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
#

app = 'entrybase-realtime-preview'
primary_region = 'iad'

[build]

[env]
APP_ENV = 'preview'

[http_service]
internal_port = 9999
force_https = true
auto_stop_machines = true
auto_start_machines = true
min_machines_running = 0
processes = ['app']

[[vm]]
memory = '1gb'
cpu_kind = 'shared'
cpus = 1
3 changes: 3 additions & 0 deletions apps/realtime/fly.toml → apps/realtime/fly.production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ primary_region = 'iad'

[build]

[env]
APP_ENV = 'production'

[http_service]
internal_port = 9999
force_https = true
Expand Down
8 changes: 6 additions & 2 deletions apps/realtime/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,15 @@ impl From<JsonRejection> for APIError {
enum AppEnv {
Dev,
Prod,
Preview,
}

impl fmt::Display for AppEnv {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
AppEnv::Dev => write!(f, "dev"),
AppEnv::Prod => write!(f, "prod"),
AppEnv::Prod => write!(f, "production"),
AppEnv::Preview => write!(f, "preview"),
}
}
}
Expand All @@ -72,7 +74,8 @@ struct UpdatePayload {
#[tokio::main]
async fn main() {
let app_env = match env::var("APP_ENV") {
Ok(v) if v == "prod" => AppEnv::Prod,
Ok(v) if v == "production" => AppEnv::Prod,
Ok(v) if v == "preview" => AppEnv::Preview,
_ => AppEnv::Dev,
};

Expand All @@ -84,6 +87,7 @@ async fn main() {
Err(e) => println!("Could not load .env file: {e}"),
};
}

let clerk_secret_key = env::var("CLERK_SECRET_KEY").expect("CLERK_SECRET_KEY not set");

let connected_waitlists: ClientList = Arc::new(Mutex::new(HashMap::new()));
Expand Down

0 comments on commit 17ec130

Please sign in to comment.