diff --git a/.github/workflows/deploy_api.yml b/.github/workflows/deploy_api.yml
index 79c336e..45cb235 100644
--- a/.github/workflows/deploy_api.yml
+++ b/.github/workflows/deploy_api.yml
@@ -2,15 +2,15 @@ name: Deploy API
on:
push:
- branches: ['main']
- paths: ['api/**']
-
-env:
- REGISTRY: ghcr.io
+ branches:
+ - main
+ paths:
+ - api/**
+ - .github/workflows/deploy_api.yml
jobs:
build-and-push:
- name: Build Docker image and push to GitHub Container Registry
+ name: Deploy to Fly.io
runs-on: ubuntu-latest
defaults:
@@ -19,40 +19,10 @@ jobs:
permissions:
contents: read
- packages: write
steps:
- uses: actions/checkout@v3
- - uses: docker/login-action@v2
- with:
- registry: ${{ env.REGISTRY }}
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
- - uses: docker/metadata-action@v4
- id: meta
- with:
- images: ${{ env.REGISTRY }}/${{ github.repository }}/api
- - uses: docker/build-push-action@v4
- with:
- context: .
- push: true
- tags: ${{ steps.meta.outputs.tags }}
- labels: ${{ steps.meta.outputs.labels }}
-
- deploy:
- needs: [build-and-push]
- name: Deploy to EC2
- runs-on: ubuntu-latest
-
- steps:
- - uses: appleboy/ssh-action@master
- with:
- host: ${{ secrets.EC2_HOST }}
- username: ${{ secrets.EC2_USERNAME }}
- key: ${{ secrets.EC2_SSH_KEY }}
- script: |
- docker login ${{ env.REGISTRY }} -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }}
- docker pull ${{ env.REGISTRY }}/${{ github.repository }}/api:latest
- docker stop crabfit-api
- docker rm crabfit-api
- docker run -d -p 3000:3000 --name crabfit-api --env-file ./.env ${{ env.REGISTRY }}/${{ github.repository }}/api:latest
+ - uses: superfly/flyctl-actions/setup-flyctl@master
+ - run: flyctl deploy --remote-only
+ env:
+ FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }}
diff --git a/README.md b/README.md
index 8ba0b35..8526b8b 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# Crab Fit
+# Crab Fit
Align your schedules to find the perfect time that works for everyone.
Licensed under the GNU GPLv3.
diff --git a/api/fly.toml b/api/fly.toml
new file mode 100644
index 0000000..4b35a46
--- /dev/null
+++ b/api/fly.toml
@@ -0,0 +1,15 @@
+# fly.toml app configuration file generated for crabfit-api on 2023-05-16T19:42:08+10:00
+#
+# See https://fly.io/docs/reference/configuration/ for information about how to use this file.
+#
+# Note: this is used to deploy the production Crab Fit API to Fly.io
+
+app = "crabfit-api"
+primary_region = "syd"
+
+[http_service]
+ internal_port = 3000
+ force_https = true
+ auto_stop_machines = true
+ auto_start_machines = true
+ min_machines_running = 0