Update GitHub Action to deploy latest main branch. #19
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: | |
- uses: actions/checkout@v2 | |
- 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: | | |
sudo mkdir -p /opt/albertclo.com | |
cd /opt/albertclo.com | |
if [ ! -d .git ]; then | |
sudo git clone https://github.com/AlbertClo/albertclo.com . | |
else | |
sudo git fetch origin | |
fi | |
sudo git checkout main | |
sudo git pull -f |