-
Notifications
You must be signed in to change notification settings - Fork 3
63 lines (59 loc) · 2.27 KB
/
ec2-deploy.yaml
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
name: Deploy to EC2
on:
push:
branches:
- "1.x"
- "development"
workflow_dispatch:
jobs:
deploy-to-ec2:
runs-on: ubuntu-latest
environment: ${{ github.ref_name }}
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Copy folder content recursively to remote VM
uses: appleboy/[email protected]
with:
host: ${{ secrets.AWS_EC2_HOST }}
username: ${{ secrets.AWS_EC2_USERNAME }}
key: ${{ secrets.AWS_EC2_PRIVATE_SSH_KEY }}
source: .
target: ${{ secrets.AWS_EC2_TARGET_DIR }}
docker-command:
runs-on: ubuntu-latest
needs: deploy-to-ec2
environment: ${{ github.ref_name }}
steps:
- name: executing remote ssh commands using password
uses: appleboy/[email protected]
with:
host: ${{ secrets.AWS_EC2_HOST }}
username: ${{ secrets.AWS_EC2_USERNAME }}
key: ${{ secrets.AWS_EC2_PRIVATE_SSH_KEY }}
script: |
cd ${{ secrets.AWS_EC2_TARGET_DIR }}
if [ "docker-compose.${{ github.ref_name }}.yml" == "docker-compose.1.x.yml" ]; then
docker-compose -f docker-compose.${{ github.ref_name }}.yml up -d
docker exec -i phpkanvas-ecosystem composer install --no-dev --optimize-autoloader
else
docker compose -f docker-compose.${{ github.ref_name }}.yml up -d
docker exec -i phpkanvas-ecosystem composer install --optimize-autoloader
fi
docker exec -i phpkanvas-ecosystem php artisan lighthouse:cache
docker exec -i phpkanvas-ecosystem php artisan config:cache
docker restart queue
docker restart queue2
docker restart queue3
docker restart queue-notifications
docker restart queue-social
docker restart laravel-scheduler
if [ "docker-compose.${{ github.ref_name }}.yml" == "docker-compose.1.x.yml" ]; then
docker restart queue4
docker restart queue5
docker restart queue6
fi
ssh -o StrictHostKeyChecking=no ${{ secrets.AWS_EC2_USERNAME }}@${{ secrets.AWS_EC2_HOST }} "sudo supervisorctl restart octane"