Manually Trigger Git Action to deploy laravel project into EC2
Custome ssh port for security reasons
Manually Trigger Git Action to deploy laravel project into EC2
Custome ssh port for security reasons
sudo vi /etc/ssh/sshd_config

Can set multiple Port. EX
Port 22
Port 1234
Restart SSH
sudo service ssh restart
Add new port in ec2 scurity group inbound rules

Test connection
ss -tulpn | grep 1234
if restart ssh not wokring, restart ec2 instance.
Get an SSH Key
cd ~/.ssh
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

You’ll also be asked to provide a passphrase. Leave this empty since we can’t enter
cat github-actions.pub >> ~/.ssh/authorized_keys
Set Github Actions secrets and variables

Set Github Action
name: Deploy
on:
workflow_dispatch:
jobs:
Deploy:
name: Deploy to EC2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build & Deploy
env:
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
HOSTNAME: ${{secrets.SSH_HOST}}
PORT: ${{secrets.SSH_PORT}}
USER_NAME: ${{secrets.SSH_USER_NAME}}
run: |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} -p ${PORT} '
# Now we have got the access of EC2 and we will start the deploy .
cd /var/www/releases &&
'
Manually Trigger

Reference
https://gist.github.com/raviagheda/c69ae5e884f4490b1af656dbd80c00dd
메타데이터
- post_id
- c8b9fc1909a8
- slug
- manually-trigger-script-in-ec2-from-git-action-c8b9fc1909a8
- url
- https://medium.com/@lalalili/manually-trigger-script-in-ec2-from-git-action-c8b9fc1909a8
- canonical_url
- https://medium.com/@lalalili/manually-trigger-script-in-ec2-from-git-action-c8b9fc1909a8
- author_url
- https://medium.com/@lalalili
- status
- ok
- fetched_at
- 2026-07-20 17:28:32