Skip to content

Update GitHub Action to remove unnecessary checkout use. #26

Update GitHub Action to remove unnecessary checkout use.

Update GitHub Action to remove unnecessary checkout use. #26

Workflow file for this run

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: |
set -e
sudo mkdir -p /opt/albertclo.com && \
cd /opt/albertclo.com && \
sudo chown -R ec2-user:ec2-user . && \
if [ ! -d .git ]; then
git clone https://github.com/AlbertClo/albertclo.com .
fi && \
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