-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (38 loc) · 1.28 KB
/
main.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
42
43
name: Deploy Strapi CMS
# right now added for main branch
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
environment: prod
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Setup SSH Key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.EC2_SSH_KEY }}" | tr -d '\r' > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts
ls -lah ~/.ssh
cat ~/.ssh/id_rsa
- name: Test SSH Connection
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} "echo SSH Connection Successful"
- name: Deploy to EC2
run: |
ssh -o StrictHostKeyChecking=no ${{ secrets.EC2_USER }}@${{ secrets.EC2_HOST }} << 'EOF'
set -e
echo "Connected to EC2"
cd ~/website-cms || git clone https://github.com/openobserve/website-cms.git ~/website-cms
cd ~/website-cms
sudo chown -R $USER:$USER ~/website-cms
sudo chmod -R u+rwX ~/website-cms
git config --global --add safe.directory "$(pwd)"
git pull origin main
echo "${{ secrets.ENV_FILE_CONTENT }}" > .env
docker compose up -d --build
EOF