File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313 - name : Checkout code
1414 uses : actions/checkout@v3
1515
16- - name : Create SSH key from secret
16+ - name : Create SSH key to connect to EC2
1717 run : |
1818 echo "${{ secrets.EC2_SSH_KEY }}" | base64 -d > ec2_key.pem
1919 chmod 400 ec2_key.pem
2525 username : ${{ secrets.EC2_USERNAME }}
2626 key_path : ec2_key.pem
2727 script : |
28+ # Create deploy key on EC2 for private repo access
29+ echo "${{ secrets.DEPLOY_KEY }}" | base64 -d > ~/.ssh/deploy-key
30+ chmod 600 ~/.ssh/deploy-key
31+ eval "$(ssh-agent -s)"
32+ ssh-add ~/.ssh/deploy-key
33+
34+ # Clone repo if not exists, otherwise pull
35+ if [ ! -d "/home/ubuntu/skribble-app/.git" ]; then
36+ git clone git@github.com:YOUR_USERNAME/YOUR_REPO_NAME.git /home/ubuntu/skribble-app
37+ else
38+ cd /home/ubuntu/skribble-app
39+ git pull origin main
40+ fi
41+
42+ # Run docker compose
2843 cd /home/ubuntu/skribble-app
29- git pull origin main
30- docker-compose down
31- docker-compose up -d --build
44+ docker compose down
45+ docker compose up -d --build
You can’t perform that action at this time.
0 commit comments