Automatic deployment from GitHub to server via SFTP (GitHub Actions)

Sdílet
Vložit
  • čas přidán 7. 09. 2024
  • Automatically push GitHub repositories to your deployment server via SFTP.
    *Requires GitHub actions and SFTP to be configured
    Works on any deployment server platform/VPS as long as SFTP is configured (i.e. NGINX, DigitalOcean, Google Cloud Platform, AWS, Vultr)
    Workflow code: pastebin.com/q...
    (Must be placed at `.github/workflows`)

Komentáře • 53

  • @martinesche6749
    @martinesche6749 Před 3 měsíci +1

    Simple, quick, working: only 1 out of 100 youtube tutorials are like this! Thanks!!!

  • @williemaxt
    @williemaxt Před 3 lety +17

    This is the most helpful tutorial I've seen on this subject. Thank you very much !!!

    • @ravenjs
      @ravenjs  Před 3 lety +6

      Yea I've spent hours trying to figure it out at first too I'm glad it helped you

    • @rahulshah1408
      @rahulshah1408 Před 7 měsíci

      This looks like it will be the exact script I need.

  • @guydineen3905
    @guydineen3905 Před 2 lety +6

    100% best vid on doing this. And I for one appreciate how fast you move. I hate drawn out tutorials. Finally got up and running after following this. THANK YOU!!!

  • @rahulshah1408
    @rahulshah1408 Před 7 měsíci +1

    Your tutorial got me 95% there. The only reason for the missing 5% is time. I had to update checkout version and will have to create encryption key pair without a password as the sftp code cannot handle key and pass together. Thank you!

  • @user-un2qc3ih7d
    @user-un2qc3ih7d Před rokem +4

    thank you very much! You are the only person who helped me in this question!

  • @olhodetamarutaca
    @olhodetamarutaca Před rokem +1

    Excelent video!!! It worked right away! Thank you!

  • @ayazahamed8254
    @ayazahamed8254 Před 3 lety +2

    Very Useful Video Content. Thank You.

  • @hydrolien
    @hydrolien Před 2 lety

    Best CI that I can ever imagine ! Tanks a lot !

  • @_plushTeddy_
    @_plushTeddy_ Před rokem +2

    Hello, i really like your tutorial, but when i deploy the code with github, i get a permission denied error.

  • @knightjaz2598
    @knightjaz2598 Před 2 lety +1

    Thank you for this video.

  • @nagnetto14
    @nagnetto14 Před rokem +2

    with this method only the changed files are uloaded or all the files of the progect?

    • @ravenjs
      @ravenjs  Před rokem +1

      Probably all the files

  • @MoserDamasceno
    @MoserDamasceno Před 3 lety +2

    JUST PERFECT!

  • @shaharyardmg7556
    @shaharyardmg7556 Před 3 lety +4

    I've followed each and every step but its not working. I am having an error under "deploy file" when the action runs. Here is the error
    "Load key "../private_key.pem": invalid format"
    host: Permission denied (publickey,password).
    can you kindly help me out with that?

    • @ravenjs
      @ravenjs  Před 3 lety +2

      Are you getting this error from the GitHub console, or the terminal of your server?
      Have you tried deleting all the SSH keys and regenerating them? You'll also need to make sure you don't mess up the private/public key and interchange them accidentally

    • @maxwelladapoe8001
      @maxwelladapoe8001 Před 2 lety +2

      You need to explicitly force the PEM like this: ssh-keygen -m PEM when generating a new key pair as described here.
      github.com/wlixcc/SFTP-Deploy-Action/issues/1

    • @theskepticcoder7883
      @theskepticcoder7883 Před 2 lety

      same here

    • @sauer.voussoir
      @sauer.voussoir Před rokem +1

      ​@@maxwelladapoe8001 thank you it works

  • @mike_gread
    @mike_gread Před 2 lety +1

    Stupid question : would it be possible to use github as the server in FTP ?

  • @michaelcavallin8975
    @michaelcavallin8975 Před 2 lety +2

    Awesome video! I am still new to github so my question might be off but I will give it a go. I have added a .gitignore file to my root folder and when this workflow starts it doesnt "listen" to the rules of the .gitignore file. I want to ignore the same files and folders in this action as I do in the file. Is that possible?

  • @alesblaze4745
    @alesblaze4745 Před rokem

    thanks a lot man!
    btw one thing extract i want to do i want to build a jar and them transfer jar a particular directory of my remote server, how that can be done?

  • @michaelharris8040
    @michaelharris8040 Před rokem

    Do i need to manually install git on the remote server?

  • @pescadero84
    @pescadero84 Před 2 lety +1

    I have done everything as You showed in this video, but I got the following error on the fourth step (SFTP Deploy):
    remote open("/var/www/html/index.html"): Permission denied

    • @pescadero84
      @pescadero84 Před 2 lety +2

      I have changed the user permissions, now it works fine! Thanks :)
      sudo chown -R user:user /var/www/html/

  • @krolik2531
    @krolik2531 Před 3 lety +1

    Worked dude, thank you :D

  • @hamitaksln
    @hamitaksln Před 2 lety +2

    It was very helpful to me. Thanks a lot!

  • @immaculateatim4507
    @immaculateatim4507 Před 2 lety +1

    It was working well for me but when I ran the workflow, I got an error of permission denied, yet I gave myself all permissions. I would like to deploy to one of my subdomains. How do I fix this please?

    • @ravenjs
      @ravenjs  Před 2 lety +1

      Permission denied from your Linux terminal?

    • @ihenners_
      @ihenners_ Před 2 lety

      @@ravenjs I also get
      Load key "../private_key.pem": invalid format
      Permission denied, please try again.
      Permission denied, please try again.
      Followed everything exactly.

    • @sauer.voussoir
      @sauer.voussoir Před rokem

      @@ihenners_ follow the comment of @shaharyardmg7556

  • @jitendranarwaria9187
    @jitendranarwaria9187 Před 2 lety +1

    this tutorial is very helpful to me
    I have a Question
    If i have to run any command with this script after pull data how can i do ?

    • @Duconi
      @Duconi Před rokem

      Data isn't pulled, it's pushed here. So GitHub Actions is taking your repository, checks it out, loads the script by this random Chinese guy called wlixcc that provides the SFTP functionality, hands over your settings including your key to that software, which should then connect to your server and push the files onto it.
      So as SFTP uses SSH to connect to that server, there are 2 options: This connection is limited to SFTP only, in that case you can not run any commands on that webserver. Or you can connect with SSH. In that case you maybe should think about using rsync instead of SFTP. But then you can also connect via SSH and could run other commands. It's less save, though as someone who has your key, then can execute any command with that key. The risk of privilege escalation is really high in that case. So only use SSH access if you really really trust all the software, that has access to that private key or find another way to execute commands on that server.

  • @timdang7978
    @timdang7978 Před 2 lety +1

    Hi, thanks for sharing this.
    I have one problem. It is that when I delete a file on my repo and then push it in. That file on my server does not get deleted. Does anyone else have the same problem?
    Also, how can I pull changes from the server? Thanks.

    • @sibinjames9994
      @sibinjames9994 Před 2 lety

      I'm also facing same thing ,Have you got any solution for that?

    • @timdang7978
      @timdang7978 Před 2 lety +1

      @@sibinjames9994 still no :(
      I just try to make everything to work before pushing it.

    • @Duconi
      @Duconi Před rokem +2

      @@timdang7978 This tutorial uses the GitHub Action from this random Chinese guy calles wilxcc who has provided an option for that on the README file in the repo: github.com/wlixcc/SFTP-Deploy-Action
      As described there, you can set the delete_remote_files option, which "will delete all files in the remote path before upload". So if the Upload fails afterwards, that files on the server are gone. If someone accesses the page while deployment, the page is maybe as well not available for a short period of time. It would be better if this action would be more intelligent and recognizes which files are still needed and not deleting everything, but that is not implemented here, as it seems.

  • @steckrein6322
    @steckrein6322 Před 2 lety +2

    Is it possible to update multiple Servers with this method?

    • @ravenjs
      @ravenjs  Před 2 lety +1

      yes i believe it's possible to modify the job script so that it updates multiple server at once :)

    • @steckrein6322
      @steckrein6322 Před 2 lety +1

      @@ravenjs i dont think that this solution is recommendable in terms of data security

  • @benignoambus
    @benignoambus Před rokem

    I followed what you just did, but I got stock in this part. I'm not sure where did it go wrong when I'm just following what you did.
    kex_exchange_identification: read: Connection reset by peer

  • @KishanChauhan-pg9hj
    @KishanChauhan-pg9hj Před rokem

    I have SFTP but don't have SSH key, with password not working.

  • @Duconi
    @Duconi Před rokem +1

    You are basically using an GitHub Action that does the deployment for you. It's an action from wlixcc which is just a random guy from China. Have you checked it? How do you protect yourself against that person changing the code and just stealing your keys?

  • @martinradovitzky5475
    @martinradovitzky5475 Před 2 lety +2

    hi, Awsome video, can i acces instead of an ssh key with a username and password?

    • @ravenjs
      @ravenjs  Před 2 lety +1

      Haha this is what i tried to do too initially.. but i failed :(( pls do teach me if you manage to figure it out!

  • @dddobriak
    @dddobriak Před 3 lety +2

    woow thank you, how can i add some npm commands before deployment?

    • @ravenjs
      @ravenjs  Před 3 lety +4

      If you look at the code in the pastebin, you can see that under '-jobs', there's only a single job called "SFTP Deploy".
      If you want to add more build/testing jobs you can do so in the 'jobs' section but you'll need some prior knowledge about GitHub Actions; I'll paste a link below to GitHub's docs to see if it helps you
      docs.github.com/en/actions/guides/building-and-testing-nodejs

    • @dddobriak
      @dddobriak Před 3 lety +2

      ​@@ravenjs many thanks, I did it and it works fine, now i can make sass changes on github and then deploy it via ssh

    • @ravenjs
      @ravenjs  Před 3 lety +1

      @@dddobriak that's great 👍