Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Actions - copy files to VPS

I would like to solve this at a small VPS Provider:

Github worflow, when pushed files to GitHub, then "GH workflows" copies the php files to the live VPS server.

How can I copy them?

.github/workflows/vps-deploy-prod.yml:

name: vps-deploy-prod

on:
  push:
    branches:
      - master

jobs:

  build: 'VPS Run Deploy'
  runs-on: ubuntu-latest    
  steps:
    - name: 'Checkout'
      uses: action/checkout@master
    - name: 'Deploy'
      run: make vps-run-deploy

The Makefile:

##### VPS specific target
vps-run-deploy:

?? copy files via ssh scp...?
like image 935
gabor Avatar asked Nov 03 '25 11:11

gabor


1 Answers

You might consider the GitHub action appleboy/scp-action

GitHub Action for copying files and artifacts via SSH.

Here is an example in this project: renatomh/gobarber-backend/.github/workflows/main.yml:

      # Copy the repository to the directory on the server/VPS used for the application
      - name: Copy dist to VPS
        uses: appleboy/scp-action@master
        with:
          host: ${{ secrets.SSH_HOST }}
          username: ${{ secrets.SSH_USER }}
          port: ${{ secrets.SSH_PORT }}
          key: ${{ secrets.SSH_KEY }}
          # Selecting all folders except "node_modules"
          source: ".,!node_modules"
          # The path is based on the directory where the user logged into the server starts
          target: "~/app/gobarber-backend"
like image 166
VonC Avatar answered Nov 06 '25 04:11

VonC



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!