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

Update staging/prod deploy GitHub Actions #89

Merged
merged 6 commits into from
Mar 25, 2024
Merged
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
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
name: 🚀 Deploy
name: 🚀 Deploy (production)
on:
push:
branches:
- main
# - dev
pull_request:
paths-ignore:
- "README.md"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

jobs:
lint:
name: ⬣ ESLint
Expand Down Expand Up @@ -71,68 +74,20 @@ jobs:
- name: ⚡ Run vitest
run: npm run test -- --coverage

# cypress:
# name: ⚫️ Cypress
# runs-on: ubuntu-latest
# steps:
# - name: ⬇️ Checkout repo
# uses: actions/checkout@v4

# - name: 🏄 Copy test env vars
# run: cp .env.example .env

# - name: ⎔ Setup node
# uses: actions/setup-node@v4
# with:
# cache: npm
# cache-dependency-path: ./package-lock.json
# node-version: 18

# - name: 📥 Install deps
# run: npm install

# - name: ⚙️ Build
# run: npm run build

# - name: 🌳 Cypress run
# uses: cypress-io/github-action@v3
# with:
# start: npm run start:mocks
# wait-on: http://localhost:8811
# env:
# PORT: 8811

deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
# needs: [lint, typecheck, vitest, cypress]
needs: [lint, typecheck, vitest]
# only deploy main/dev branch on pushes
if: ${{ (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') && github.event_name == 'push' }}

steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 👀 Read app name
uses: SebRollen/[email protected]
id: app_name
with:
file: fly.toml
field: app

- name: 🎈 Setup Fly
uses: superfly/flyctl-actions/[email protected]

- name: 🚀 Deploy Staging
if: ${{ github.ref == 'refs/heads/dev' }}
run: flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} --app ${{ steps.app_name.outputs.value }}-staging
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

- name: 🚀 Deploy Production
if: ${{ github.ref == 'refs/heads/main' }}
run: flyctl deploy --remote-only --build-arg COMMIT_SHA=${{ github.sha }} --app ${{ steps.app_name.outputs.value }}
run: flyctl deploy --remote-only --config ./fly.production.toml --build-arg COMMIT_SHA=${{ github.sha }}
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

Expand Down
93 changes: 93 additions & 0 deletions .github/workflows/deploy.staging.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
name: 🚀 Deploy (staging)
on:
push:
tags:
- stage
branches:
- dev
paths-ignore:
- "README.md"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

jobs:
lint:
name: ⬣ ESLint
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: ./package-lock.json
node-version: 18

- name: 📥 Install deps
run: npm install

- name: 🔬 Lint
run: npm run lint

typecheck:
name: ʦ TypeScript
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: ./package-lock.json
node-version: 18

- name: 📥 Install deps
run: npm install

- name: 🔎 Type check
run: npm run typecheck --if-present

vitest:
name: ⚡ Vitest
runs-on: ubuntu-latest
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: ⎔ Setup node
uses: actions/setup-node@v4
with:
cache: npm
cache-dependency-path: ./package-lock.json
node-version: 18

- name: 📥 Install deps
run: npm install

- name: ⚡ Run vitest
run: npm run test -- --coverage

deploy:
name: 🚀 Deploy
runs-on: ubuntu-latest
needs: [lint, typecheck, vitest]
steps:
- name: ⬇️ Checkout repo
uses: actions/checkout@v4

- name: 🎈 Setup Fly
uses: superfly/flyctl-actions/[email protected]

- name: 🚀 Deploy Staging
run: flyctl deploy --remote-only --config ./fly.staging.toml --build-arg COMMIT_SHA=${{ github.sha }} --strategy bluegreen
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
47 changes: 47 additions & 0 deletions fly.production.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
app = "reactrouter"

kill_signal = "SIGINT"
kill_timeout = 5
processes = [ ]

[experimental]
allowed_public_ports = [ ]
auto_rollback = true
cmd = "start.sh"
entrypoint = "sh"

[[services]]
internal_port = 8_080
processes = [ "app" ]
protocol = "tcp"
script_checks = [ ]

[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"

[[services.ports]]
handlers = [ "http" ]
port = 80
force_https = true

[[services.ports]]
handlers = [ "tls", "http" ]
port = 443

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

[[services.http_checks]]
interval = 10_000
grace_period = "5s"
method = "get"
path = "/healthcheck"
protocol = "http"
timeout = 2_000
tls_skip_verify = false
headers = { }
47 changes: 47 additions & 0 deletions fly.staging.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
app = "reactrouterdotcomstaging"

kill_signal = "SIGINT"
kill_timeout = 5
processes = [ ]

[experimental]
allowed_public_ports = [ ]
auto_rollback = true
cmd = "start.sh"
entrypoint = "sh"

[[services]]
internal_port = 8_080
processes = [ "app" ]
protocol = "tcp"
script_checks = [ ]

[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"

[[services.ports]]
handlers = [ "http" ]
port = 80
force_https = true

[[services.ports]]
handlers = [ "tls", "http" ]
port = 443

[[services.tcp_checks]]
grace_period = "1s"
interval = "15s"
restart_limit = 0
timeout = "2s"

[[services.http_checks]]
interval = 10_000
grace_period = "5s"
method = "get"
path = "/healthcheck"
protocol = "http"
timeout = 2_000
tls_skip_verify = false
headers = { }
46 changes: 0 additions & 46 deletions fly.toml

This file was deleted.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"lint:fix": "npm run lint -- --fix",
"start": "remix-serve build/index.js",
"test": "vitest",
"typecheck": "tsc -b"
"typecheck": "tsc -b",
"push:stage": "git tag -f stage && git push origin stage -f"
},
"prettier": {},
"eslintIgnore": [
Expand Down