mirror of
				https://github.com/SamKirkland/FTP-Deploy-Action.git
				synced 2025-10-31 20:14:01 +00:00 
			
		
		
		
	ARGS pass through props feature
Added ARGS option Added some more examples
This commit is contained in:
		
							parent
							
								
									25b4cb7043
								
							
						
					
					
						commit
						2c3915c100
					
				| @ -1,4 +1,4 @@ | ||||
| FROM alpine:latest | ||||
| FROM alpine:3.10 | ||||
| 
 | ||||
| LABEL version="1.0.0" | ||||
| LABEL repository="https://github.com/SamKirkland/FTP-Deploy-Action" | ||||
|  | ||||
							
								
								
									
										138
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										138
									
								
								README.md
									
									
									
									
									
								
							| @ -1,11 +1,11 @@ | ||||
| # FTP Deploy for GitHub Actions | ||||
| # FTP Deploy GitHub Action | ||||
| 
 | ||||
| Automate deploying websites and more with this GitHub action. | ||||
| 
 | ||||
|  | ||||
|  | ||||
| 
 | ||||
| ### Usage (Your_Project/.github/workflows/main.yml) | ||||
| ``` | ||||
| ### Usage Example (Your_Project/.github/workflows/main.yml) | ||||
| ```shell | ||||
| on: push | ||||
| name: Publish Website | ||||
| jobs: | ||||
| @ -17,9 +17,11 @@ jobs: | ||||
|     - name: FTP-Deploy-Action | ||||
|       uses: SamKirkland/FTP-Deploy-Action@master | ||||
|       env: | ||||
|         FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} | ||||
|         FTP_SERVER: ${{ secrets.FTP_SERVER }} | ||||
|         FTP_SERVER: ftp.samkirkland.com | ||||
|         FTP_USERNAME: ${{ secrets.FTP_USERNAME }} | ||||
|         FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} | ||||
|         ARGS: --delete | ||||
|         # --delete arg will delete files on the server if you've deleted them in git | ||||
| ``` | ||||
| 
 | ||||
| 1. Select the repository you want to add the action to | ||||
| @ -27,37 +29,100 @@ jobs: | ||||
| 3. Select `Blank workflow file` or `Set up a workflow yourself`, if you don't see these options manually create a yaml file `Your_Project/.github/workflows/main.yml` | ||||
| 4. Paste the above code into your file and save | ||||
| 7. Now you need to add a few keys to the `secrets` section in your project, the following are required at a minimum. To add a `secret` go to the `Settings` tab in your project then select `Secrets`. Add a new `Secret` for each of the following | ||||
|    * FTP_SERVER | ||||
|    * FTP_USERNAME | ||||
|    * FTP_PASSWORD | ||||
|    * FTP_SERVER | ||||
|    * (see optional settings below) | ||||
| 
 | ||||
| ### Settings | ||||
| To add a `secret` go to the `Settings` tab in your project then select `Secrets`. Add a new `Secret` for each of the following | ||||
| To add a `secret` go to the `Settings` tab in your project then select `Secrets`. Add a new `Secret` for each of the following. | ||||
| I recommend you use a secrets to store your FTP_USERNAME and FTP_PASSWORD. | ||||
| 
 | ||||
| | Key Name       | Required? | Example                     | Default | Description | | ||||
| |----------------|-----------|-----------------------------|---------|-------------| | ||||
| | `FTP_SERVER`   | Yes       | ftp.samkirkland.com         | N/A     | FTP server name (you may need to specify a port) | | ||||
| | `FTP_USERNAME` | Yes       | git-action@samkirkland.com  | N/A     | FTP account username | | ||||
| | `FTP_PASSWORD` | Yes       | CrazyUniquePassword&%123    | N/A     | FTP account password | | ||||
| | `LOCAL_DIR`    | No        | build                       | . (root project folder) | The local folder to copy, defaults to root project folder. Do NOT include slashes for folders. | | ||||
| | `REMOTE_DIR`   | No        | serverFolder                | . (root FTP folder) | The remote folder to copy to, deafults to root FTP folder (I recommend you configure this on your server side instead of here). Do NOT include slashes for folders.  | | ||||
| | `ARGS`         | No        | See `Commonly used ARGS` section below  | N/A     | Custom lftp arguments, this field is passed through directly into the lftp script. | | ||||
| 
 | ||||
| #### Commonly used ARGS | ||||
| Custom lftp arguments, this field is passed through directly into the lftp script. See [lftp's website](https://lftp.yar.ru/lftp-man.html) for all options. | ||||
| You can use as many arguments as you want, seperate them with a space | ||||
| | ARG                 | Description                                                      | | ||||
| |---------------------|------------------------------------------------------------------| | ||||
| | `--delete`          | Delete files not present at the source                           | | ||||
| | `--transfer-all`    | Transfer  all  files, even seemingly the same at the target site | | ||||
| | `--dry-run`         | Ouputs a list of files that will be created/modified to sync your source without making any actual changes | | ||||
| | `--include-glob=GP` | Include matching files (GP is a glob pattern, e.g. `*.zip')      | | ||||
| | `--exclude-glob=GP` | Exclude matching files (GP is a glob pattern, e.g. `*.zip')      | | ||||
| | `--no-empty-dirs`   | Don't create empty directories                                   | | ||||
| 
 | ||||
| | Secret Key Name | Required? | Example                     | Default | Description | | ||||
| |-----------------|-----------|-----------------------------|---------|-------------| | ||||
| | FTP_USERNAME    | Yes       | git-action@samkirkland.com  | N/A     | FTP account username | | ||||
| | FTP_PASSWORD    | Yes       | CrazyUniquePassword&%123    | N/A     | FTP account password | | ||||
| | FTP_SERVER      | Yes       | ftp.samkirkland.com         | N/A     | FTP server name (you may need to specify a port) | | ||||
| | LOCAL_DIR       | No        | build                       | N/A (root project folder) | The local folder to copy, defaults to root project folder | | ||||
| | REMOTE_DIR      | No        | serverFolder                | N/A (root FTP folder) | The remote folder to copy to, deafults to root FTP folder (I recommend you configure this on your server side instead of here)  | | ||||
| 
 | ||||
| 
 | ||||
| ## Common Examples | ||||
| - [Building and deploying a javascript website](https://github.com/SamKirkland/FTP-Deploy-Action-Example-React) | ||||
| - Want another example? Let me know by creating a github issue | ||||
| 
 | ||||
| 
 | ||||
| ### What does this action do exactly? | ||||
| - This action is triggered by a `event` on your repo | ||||
| - A docker image based on `mwienk/docker-lftp` is spun up on github servers | ||||
| - The docker container compresses your code into a tar.gz file | ||||
| - The file is then uploaded to the remote server | ||||
| - The file is then un-zipped | ||||
| 
 | ||||
| ### Deprecated main.workflow config (used for beta/legacy apps that haven't been migrated to .yaml workflows yet) | ||||
| ### Build and Publish React/Angular/Vue/Node Website | ||||
| Make sure you have an npm script named 'build'. This config should work for most node built websites | ||||
| ```shell | ||||
| on: push | ||||
| name: Build and Publish Front End Framework Website | ||||
| jobs: | ||||
|   fTP-Deploy-Action: | ||||
|     name: FTP-Deploy-Action | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|     - uses: actions/checkout@master | ||||
|      | ||||
|     - name: Use Node.js 12.x | ||||
|       uses: actions/setup-node@v1 | ||||
|       with: | ||||
|         node-version: '12.x' | ||||
|          | ||||
|     - name: Build Project | ||||
|       run: | | ||||
|         npm install | ||||
|         npm run build --if-present | ||||
|          | ||||
|     - name: List output files | ||||
|       run: ls | ||||
|        | ||||
|     - name: FTP-Deploy-Action | ||||
|       uses: SamKirkland/FTP-Deploy-Action@master | ||||
|       env: | ||||
|         FTP_SERVER: ftp.samkirkland.com | ||||
|         FTP_USERNAME: ${{ secrets.FTP_USERNAME }} | ||||
|         FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} | ||||
|         LOCAL_DIR: build | ||||
|         ARGS: --delete | ||||
| ``` | ||||
| 
 | ||||
| ### Log only dry run: Use this mode for testing | ||||
| Ouputs a list of files that will be created/modified to sync your source without making any actual changes | ||||
| ```shell | ||||
| on: push | ||||
| name: Publish Website Dry Run | ||||
| jobs: | ||||
|   fTP-Deploy-Action: | ||||
|     name: FTP-Deploy-Action | ||||
|     runs-on: ubuntu-latest | ||||
|     steps: | ||||
|     - uses: actions/checkout@master | ||||
|     - name: FTP-Deploy-Action | ||||
|       uses: SamKirkland/FTP-Deploy-Action@master | ||||
|       env: | ||||
|         FTP_SERVER: ftp.samkirkland.com | ||||
|         FTP_USERNAME: ${{ secrets.FTP_USERNAME }} | ||||
|         FTP_PASSWORD: ${{ secrets.FTP_PASSWORD }} | ||||
|         ARGS: --delete --dry-run | ||||
| ``` | ||||
| 
 | ||||
| ##### Want another example? Let me know by creating a github issue | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| #### Deprecated main.workflow config (used for beta/legacy apps that haven't been migrated to .yaml workflows yet) | ||||
| ```json | ||||
| action "FTP-Deploy-Action" { | ||||
|    uses = "SamKirkland/FTP-Deploy-Action@master" | ||||
|    secrets = ["FTP_USERNAME", "FTP_PASSWORD", "FTP_SERVER"] | ||||
| @ -65,7 +130,7 @@ action "FTP-Deploy-Action" { | ||||
| ``` | ||||
| 
 | ||||
| ### Debugging locally | ||||
| ###### Instructions for windows | ||||
| ##### Instructions for debugging on windows | ||||
| - Install docker for windows | ||||
| - Open powershell | ||||
| - Navigate to the repo folder | ||||
| @ -76,19 +141,12 @@ action "FTP-Deploy-Action" { | ||||
|   - Run this command every time you modify entrypoint.sh `.\dos2unix.exe "{FULL_PATH_TO_REPO\entrypoint.sh}"` | ||||
| - Run `docker run action` | ||||
|    | ||||
| ###### Instructions for linux | ||||
| ##### Instructions for debugging on linux | ||||
| - Please submit a PR for linux instructions :) | ||||
| 
 | ||||
| 
 | ||||
| ### ToDo | ||||
| - More config options | ||||
|    - Deploy Mode: ${DEPLOY_MODE} `full`|`diffs` | ||||
| - SSH support | ||||
| - Switch from lftp to git | ||||
| #### ToDo | ||||
| - SFTP example | ||||
| - More examples | ||||
| 
 | ||||
| Pull Requests Welcome! | ||||
| 
 | ||||
| ### License | ||||
| ---- | ||||
| 
 | ||||
| MIT | ||||
| #### Pull Requests Welcome! | ||||
|  | ||||
							
								
								
									
										36
									
								
								action.yml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										36
									
								
								action.yml
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,36 @@ | ||||
| name: 'FTP Deploy' | ||||
| description: 'Syncs files via FTP to a remote server' | ||||
| inputs: | ||||
|   ftp_server: | ||||
|     description: 'FTP server name (you may need to specify a port)' | ||||
|     required: true | ||||
|   ftp_username: | ||||
|     description: 'FTP account username' | ||||
|     required: true | ||||
|   ftp_password: | ||||
|     description: 'FTP account password' | ||||
|     required: true | ||||
|   local_dir: | ||||
|     description: 'The local folder to copy, defaults to root project folder' | ||||
|     required: false | ||||
|     default: '' | ||||
|   remote_dir: | ||||
|     description: 'The remote folder to copy to, deafults to root FTP folder (I recommend you configure this on your server side instead of here)' | ||||
|     required: false | ||||
|     default: '' | ||||
|   ARGS: | ||||
|     description: 'Passes through options into lftp' | ||||
|     required: false | ||||
|     default: "" | ||||
| runs: | ||||
|   using: 'docker' | ||||
|   image: 'Dockerfile' | ||||
|   args: | ||||
|     - ${{ inputs.ftp_server }} | ||||
|     - ${{ inputs.ftp_username }} | ||||
|     - ${{ inputs.ftp_password }} | ||||
|     - ${{ inputs.local_dir }} | ||||
|     - ${{ inputs.remote_dir }} | ||||
| branding: | ||||
|   icon: 'pload-cloud'   | ||||
|   color: 'orange' | ||||
| @ -9,7 +9,7 @@ echo "Uploading files..." | ||||
| WDEFAULT_LOCAL_DIR=${LOCAL_DIR:-"."} | ||||
| WDEFAULT_REMOTE_DIR=${REMOTE_DIR:-"."} | ||||
| 
 | ||||
| lftp $FTP_SERVER -u $FTP_USERNAME,$FTP_PASSWORD -e "set ftp:ssl-allow no; mirror -R $WDEFAULT_LOCAL_DIR $WDEFAULT_REMOTE_DIR; quit" | ||||
| lftp $FTP_SERVER -u $FTP_USERNAME,$FTP_PASSWORD -e "set ftp:ssl-allow no; mirror $ARGS -R $WDEFAULT_LOCAL_DIR $WDEFAULT_REMOTE_DIR; quit" | ||||
| 
 | ||||
| echo "FTP Deploy Complete" | ||||
| exit 0 | ||||
							
								
								
									
										
											BIN
										
									
								
								images/action-preview.gif
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								images/action-preview.gif
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 168 KiB | 
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 18 KiB | 
							
								
								
									
										
											BIN
										
									
								
								images/env.png
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								images/env.png
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							| Before Width: | Height: | Size: 17 KiB | 
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user