This GitHub Action automatically transfers files listed in a .scps
file in your project to a remote server using SCP.
Create .scps file in the root of the project, list all relative paths of the files that will be transfered to the server.
Name | Description | Required |
---|---|---|
remote-user |
Username for the remote server. | Yes |
remote-host |
Remote server address. | Yes |
remote-path |
Destination path on the remote server. | Yes |
ssh-key-path |
SSH private key path for authentication. | Yes |
Name | Description |
---|---|
transfer-status |
Status of the SCP transfer. |
name: Deploy Files to Remote Server
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Add SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.YOUR_EC2_SSH_KEY }}" > ~/.example-ssh/your-ec2-pri-key.pem
chmod 600 ~/.example-ssh/your-ec2-pri-key.pem
- name: SCP Transfer Files
uses: reene444/[email protected]
with:
remote-user: "ubuntu"
remote-host: "ec2-example.com"
remote-path: "~/deploy/"
ssh-key-path: "~/.example-ssh/your-ec2-pri-key.pem"