-
Notifications
You must be signed in to change notification settings - Fork 0
41 lines (40 loc) · 1.28 KB
/
deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
name: Deploy to EC2
on:
pull_request:
types: [closed]
workflow_dispatch:
inputs:
deployment_type:
description: 'Deploy to EC2'
required: true
type: choice
options:
- 'full-rebuild'
- 'app-only'
- 'none'
default: 'none'
jobs:
deploy:
runs-on: ubuntu-latest
if: |
(github.event_name == 'workflow_dispatch' && github.event.inputs.deployment_type != 'none') ||
(github.event_name == 'pull_request' && github.event.pull_request.merged == true && contains(github.event.pull_request.labels.*.name, 'deploy'))
steps:
- name: Deploy to EC2
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USER }}
key: ${{ secrets.EC2_SSH_KEY }}
script: |
cd ~/geoChat/
if [[ "${{ github.event.inputs.deployment_type }}" == "full-rebuild" ]]; then
docker compose down
git pull origin main
docker compose up -d --build
docker system prune -a -f --volumes=false --filter "until=24h"
else
git pull origin main
docker compose up -d --build app
docker image prune -f
fi