Learn how to host your resume on an AWS EC2 instance and automate deployment using GitHub Actions.
Log in to your AWS Management Console and navigate to the EC2 dashboard.
Inbound Rules (Add Rule):
- Type: SSH, Port Range: 22, Source: Anywhere-IPv4 (0.0.0.0/0)
- Type: HTTP, Port Range: 80, Source: Anywhere-IPv4 (0.0.0.0/0)
- Type: HTTPS, Port Range: 443, Source: Anywhere-IPv4 (0.0.0.0/0)
Create a new GitHub repository and upload the files for your resume (e.g., index.html, style.css, etc.).
ec2-xx-xxx-xxx.compute-x.amazonaws.com
).github/workflows
in your repositorygithub-actions-ec2.yml
in the workflows foldername: Push-to-EC2 # Trigger deployment only on push to main branch on: push: branches: - main jobs: deploy: name: Deploy to EC2 on master branch push runs-on: ubuntu-latest steps: - name: Checkout the files uses: actions/checkout@v2 - name: Deploy to Server 1 uses: easingthemes/ssh-deploy@main env: SSH_PRIVATE_KEY: ${{ secrets.EC2_SSH_KEY }} REMOTE_HOST: ${{ secrets.HOST_DNS }} REMOTE_USER: ${{ secrets.USERNAME }} TARGET: ${{ secrets.TARGET_DIR }} - name: Executing remote ssh commands using ssh key uses: appleboy/ssh-action@master with: host: ${{ secrets.HOST_DNS }} username: ${{ secrets.USERNAME }} key: ${{ secrets.EC2_SSH_KEY }} script: | sudo apt-get -y update sudo apt-get install -y apache2 sudo systemctl start apache2 sudo systemctl enable apache2 cd home sudo mv * /var/www/html
Click Commit Changes
After setting up the above steps, any change committed to the Code will automatically reflect on the instance.