sand4rt / ftp-deployer

Simple SFTP / FTP deployment with NodeJS.
https://github.com/marketplace/actions/ftp-deployer
MIT License
47 stars 12 forks source link

Error not bubbling up to github workflow #6

Closed cgsmith closed 1 year ago

cgsmith commented 3 years ago

The github workflow still succeeds at this point but should fail.

image

sand4rt commented 3 years ago

Thanks for creating an issue. I'll look into this when I have the time. You could also create a PR yourself if you want.

hwalker928 commented 3 years ago

I am having the same issue. I am trying to get it to just upload the entire repo to the SFTP.

sand4rt commented 3 years ago

This is how you can test the deployment:

  1. create a test-action.js in the root of the git repository
  2. run npm install && npm run build
  3. Paste the code below in the created test-action.js
  4. Change the host, user, password properties
  5. run node test-action.js
const core = require('@actions/core');
const FtpDeploy = require('ftp-deploy');

core.info('Deploying...');

new FtpDeploy()
    .deploy({
        sftp: true,
        host: 'test.rebex.net',
        port: 22,
        user: 'demo',
        password: 'password',
        remoteRoot: './',
        localRoot: 'dist',
        include:  ['dist'],
        exclude: ['node_modules/**', 'node_modules/**/.*', '.git/**']
    }) 
    .then(response => core.info('Deploy finished:', response))
    .catch(error => core.error(error));
cgsmith commented 3 years ago

@hwalker928 I did setup a workflow for uploading only the changed files for our development deploy process. See below:

Our local folder is set for this: /home/runner/work/github-project-name/github-project-name

# This is a basic workflow to help you get started with Actions
name: Deploy to Develop

# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: [ develop ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  deploy:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest

    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
      - uses: actions/checkout@v2
        with:
         fetch-depth: 2
      - name: Set ENV variable
        run: echo "FILES_TO_UPLOAD=$(git diff-tree --no-commit-id --name-only -r ${{ github.sha }} | sed ':a; N; $!ba; s/\n/", "/g' | sed 's/.*/["&"]/')" >> $GITHUB_ENV
      - name: SFTP Deploy
        uses: CGSmith-LLC/ftp-deployer@master
        id: sftp
        with:
          sftp: true
          port: 22
          host: ${{ secrets.DEV_SFTP_HOST }}
          username: ${{ secrets.DEV_SFTP_USER }}
          password: ${{ secrets.DEV_SFTP_PASSWORD }}
          remote_folder: ${{ secrets.DEV_SFTP_DIR }}
          include: ${{ env.FILES_TO_UPLOAD }}
          local_folder: ${{ secrets.DEV_SFTP_LOCAL_DIR }}
      - name: Notify via Slack
        env:
          SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
        uses: act10ns/slack@v1
        with: 
            status: ${{ job.status }}
            channel: ${{ secrets.SLACK_CHANNEL }}
        if: always()
sand4rt commented 1 year ago

This is fixed in v1.7