Test 3 #32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to EC2 | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
start: | |
runs-on: ubuntu-latest | |
steps: | |
- name: AWS SSM Send-Command | |
uses: peterkimzz/aws-ssm-send-command@master | |
id: ssm | |
with: | |
aws-region: ${{ secrets.AWS_REGION }} | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
instance-ids: ${{ secrets.INSTANCE_ID }} | |
working-directory: /home/ec2-user | |
command: | | |
export HOME=/home/ec2-user | |
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 . | |
fi && \ | |
git config --global --add safe.directory /opt/albertclo.com && \ | |
git add -A && git reset HEAD --hard && \ | |
git checkout main && \ | |
git fetch origin && \ | |
git reset --hard origin/main && \ | |
docker-compose --env-file .env -f infra/docker/docker-compose.yml exec php php artisan migrate && \ | |
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 node npm run build |