Skip to content

Commit

Permalink
hotfix: add deployment script for prod
Browse files Browse the repository at this point in the history
  • Loading branch information
typeofweb committed Jan 4, 2023
1 parent 1666164 commit 9a9587b
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 0 deletions.
55 changes: 55 additions & 0 deletions .github/workflows/deploy-api-prod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Fly Deploy PRODUCTION
on:
workflow_dispatch:
push:
branches:
- main
jobs:
deploy:
name: Deploy API
runs-on: ubuntu-latest
environment: api
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Fail if branch is not main
if: github.event_name == 'workflow_dispatch' && github.ref != 'refs/heads/main'
run: |
echo "This workflow should not be triggered with workflow_dispatch on a branch other than main"
exit 1
- name: Create GitHub deployment
uses: chrnorm/deployment-action@v2
id: deployment
with:
token: "${{ github.token }}"
environment-url: https://api.devfaq.pl
environment: api

- name: Prepare flyctl
uses: superfly/flyctl-actions/setup-flyctl@master

- name: Deploy to fly.io
run: flyctl deploy --config apps/api/fly.production.toml --remote-only -e GIT_BRANCH=$(git rev-parse --abbrev-ref HEAD) -e GIT_COMMIT_HASH=$(git rev-parse HEAD)
env:
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}

- name: Update deployment status (success)
if: success()
uses: chrnorm/deployment-status@v2
with:
token: "${{ github.token }}"
environment-url: ${{ steps.deployment.outputs.environment_url }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
state: "success"

- name: Update deployment status (failure)
if: failure()
uses: chrnorm/deployment-status@v2
with:
token: "${{ github.token }}"
environment-url: ${{ steps.deployment.outputs.environment_url }}
deployment-id: ${{ steps.deployment.outputs.deployment_id }}
state: "failure"
45 changes: 45 additions & 0 deletions apps/api/fly.production.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# fly.toml file generated for devfaq-api on 2022-11-19T13:46:34+01:00

app = "devfaq-api-production"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[env]
PORT = "8080"

[build]
dockerfile = "Dockerfile"

[deploy]
release_command = "pnpm --filter=api exec prisma migrate deploy"

[experimental]
allowed_public_ports = []
auto_rollback = true

[[services]]
http_checks = []
internal_port = 8080
processes = ["app"]
protocol = "tcp"
script_checks = []
[services.concurrency]
hard_limit = 25
soft_limit = 20
type = "connections"

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

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

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

0 comments on commit 9a9587b

Please sign in to comment.