Skip to content

Test 11

Test 11 #72

Workflow file for this run

name: Deploy to EC2
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.AWS_INSTANCE_SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Deploy to EC2
env:
HOST: ec2-user@${{ secrets.AWS_INSTANCE_IP }}
run: |
ssh -i StrictHostKeyChecking=accept-new [email protected] "
set -e
sudo mkdir -p /opt/albertclo.com
sudo chown -R ec2-user:ec2-user /opt/albertclo.com
cd /opt/albertclo.com
if [ ! -d .git ]; then git clone https://github.com/AlbertClo/albertclo.com.git . ; fi
git config --global --add safe.directory /opt/albertclo.com
git remote set-url origin https://github.com/AlbertClo/albertclo.com.git
git add -A
git reset HEAD --hard
git checkout main || exit 1
git fetch origin
git reset --hard origin/main
docker-compose --env-file .env -f infra/docker/docker-compose.yml up -d
docker-compose --env-file .env -f infra/docker/docker-compose.yml exec php composer install
docker-compose --env-file .env -f infra/docker/docker-compose.yml exec php php artisan migrate
echo 'done'"