Merge pull request #258 from GRA0007/chore/setup-workflow
Setup API deployment workflow
This commit is contained in:
commit
49c6281b74
50
.github/workflows/deploy_api.yml
vendored
50
.github/workflows/deploy_api.yml
vendored
|
|
@ -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 }}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Crab Fit <img width="100" align="right" src="crabfit-frontend/src/res/logo.svg" alt="avatar">
|
||||
# Crab Fit <img width="100" align="right" src="frontend/src/res/logo.svg" alt="avatar">
|
||||
|
||||
Align your schedules to find the perfect time that works for everyone.
|
||||
Licensed under the GNU GPLv3.
|
||||
|
|
|
|||
15
api/fly.toml
Normal file
15
api/fly.toml
Normal file
|
|
@ -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
|
||||
Loading…
Reference in a new issue