Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

web deploy anything

Actions
Deploy websites via sftp/ssh/rsync
v1
Latest
Star (238)

web deploy - Continuous integration for everyone

Automate deploying websites and more with this GitHub action.It's free!

tests


Usage Example

Place the following inYour_Project/.github/workflows/main.yml

on:pushname:Publish Websitejobs:web-deploy:name:🚀 Deploy Website Every Commitruns-on:ubuntu-lateststeps:    -name:🚚 Get Latest Codeuses:actions/checkout@v3        -name:📂 Sync Filesuses:SamKirkland/web-deploy@v1with:target-server:example.comremote-user:usernameprivate-ssh-key:${{ secrets.SSH_KEY }}destination-path:~/destinationFolder/

Requirements

  • You must have shell access to your server, please read you webite hosts documentation
  • You CANNOT use a FTP account - they are not the same!
  • You will need to create aSSH user to deploy. Normally this is your cpanel or hosting providers username and password
  • Most web hosts change the default port (22), check with your host for your port number

Setup Steps

  1. Select the repository you want to add the action to
  2. Select theActions tab
  3. SelectBlank workflow file orSet up a workflow yourself, if you don't see these options manually create a yaml fileYour_Project/.github/workflows/main.yml
  4. Paste the example above into your yaml file and save
  5. Now you need to add a key to thesecrets section in your project. To add asecret go to theSettings tab in your project then selectSecrets. Add a newSecret forprivate-ssh-key
  6. Update your yaml file settings

Settings

Keys can be added directly to your .yml config file or referenced from your projectSecrets storage.

To add asecret go to theSettings tab in your project then selectSecrets.I strongly recommend you store yourprivate-ssh-key as a secret.

Key NameRequired?ExampleDefaultDescription
target-serverYesexample.comDestination server to deploy to
destination-pathYes~/folderOnServerThatAlreadyExists/Path on the server to deploy to. Must already exist.
remote-userYesusernameSSH user to login as
private-ssh-keyYes-----BEGIN RSA PRIVATE KEY----- ......SSH Private key. Must be specified as a secret.
source-pathNo./myFolderToPublish/./Path to upload to on the server, must end with trailing slash/
ssh-portNo1234522SSH port to use. Most hosts change this from the default. This is NOT your websites port.
rsync-optionsNoSeersync-options section below--archive --verbose --compress --human-readable --progress --delete-after --exclude=.git* --exclude=.git/ --exclude=README.md --exclude=readme.md --exclude=.gitignoreNote: If customizing you should re-specify defaults (assuming you want them). Custom rsync arguments, this field is passed through directly into the rsync script.

Advanced options usingrsync-options

Custom arguments, this field is passed through directly into the rsync script. Seersync's manual for all options.You can use as many arguments as you want, seperate them with a space

Below is an incomplete list of commonly used args:

OptionDescription
--archiveA quick way of saying you want recursion and want to preserve almost everything
--dry-runDoes not upload or delete anything, but tells you what it would upload/delete if this was a real deploy
--statsPrint verbose statistics on the file transfer, allowing you to tell how effective rsync’s delta-transfer algorithm is for your data
--linksWhen symlinks are encountered, recreate the symlink on the destination
--compressCompresses the file data as it is sent to the destination machine, which reduces the amount of data being transmitted
--human-readableOutput bytes in a more human-readable format (K, M, G)
--itemize-changesitemized list of the changes that are being made to each file, including attribute changes
--delete-afterWhen you delete a file on github it will also be deleted on the server. Files are deleted at the end of a deployment to minimize downtime.
--max-size '200K'Ignore syncing files over this limit. Value is a number followed by "K", "M", or "G"
--exclude 'file.txt'Excludes file(s) from the deployment. Supports glob pattterns (ex:*.jpg). You can have multiple excludes!
--include 'file.txt'Includes file(s) even if it was excluded. Supports glob pattterns (ex:*.jpg). You can have multiple includes!

Seersync's manual for all options

Common Examples

Build and Publish React/Angular/Vue Website

Make sure you have an npm script named 'build'. This config should work for most node built websites.

on:pushname:Publish Websitejobs:web-deploy:name:🚀 Deploy Website Every Commitruns-on:ubuntu-lateststeps:    -name:🚚 Get Latest Codeuses:actions/checkout@v3    -name:📦 Install Packages    -uses:actions/setup-node@v3with:node-version:18cache:"npm"    -run:npm ci          -name:🔨 Buildrun:npm run build        -name:📂 Sync Filesuses:SamKirkland/web-deploy@v1with:target-server:example.comremote-user:usernameprivate-ssh-key:${{ secrets.SSH_KEY }}destination-path:~/destinationFolder/

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

on:pushname:Publish Website Dry Runjobs:web-deploy:name:🚀 Deploy Website Every Commitruns-on:ubuntu-lateststeps:    -name:🚚 Get Latest Codeuses:actions/checkout@v3    -name:📂 Sync Filesuses:SamKirkland/web-deploy@v1with:target-server:example.comremote-user:usernameprivate-ssh-key:${{ secrets.SSH_KEY }}ssh-port:22destination-path:~/destinationFolder/rsync-options:--dry-run --archive --verbose --compress --delete-after --human-readable --exclude=.git* --exclude=.git/ --exclude=README.md --exclude=readme.md --exclude=.gitignore

Want another example? Let me know by creating agithub issue


Badge

If you appreciate this github action give it a ⭐ or show off with one of the badges below. Feel free to edit the text or color.

Deployed with web deploy

[<imgalt="Deployed with web deploy"src="https://img.shields.io/badge/Deployed With-web deploy-%3CCOLOR%3E?style=for-the-badge&color=0077b6">](https://github.com/SamKirkland/web-deploy)

Deployed with web deploy

[<imgalt="Deployed with web deploy"src="https://img.shields.io/badge/Deployed With-web deploy-%3CCOLOR%3E?style=for-the-badge&color=2b9348">](https://github.com/SamKirkland/web-deploy)

Deployed with web deploy

[<imgalt="Deployed with web deploy"src="https://img.shields.io/badge/Deployed With-web deploy-%3CCOLOR%3E?style=for-the-badge&color=d00000">](https://github.com/SamKirkland/web-deploy)

Website Deployed for Free with web deploy

[<imgalt="Website Deployed for Free with web deploy"src="https://img.shields.io/badge/Website deployed for free with-web deploy-%3CCOLOR%3E?style=for-the-badge&color=297FA9">](https://github.com/SamKirkland/web-deploy)

Website Deployed for Free with web deploy

[<imgalt="Website Deployed for Free with web deploy"src="https://img.shields.io/badge/Website deployed for free with-web deploy-%3CCOLOR%3E?style=for-the-badge&color=2b9348">](https://github.com/SamKirkland/web-deploy)

Website Deployed for Free with web deploy

[<imgalt="Website Deployed for Free with web deploy"src="https://img.shields.io/badge/Website deployed for free with-web deploy-%3CCOLOR%3E?style=for-the-badge&color=d00000">](https://github.com/SamKirkland/web-deploy)

FAQ

How to exclude .git files from the publish

Git files are excluded by default

If have customizedrsync-options you will need to re-add the default exclude options using--exclude=.git* --exclude=.git/ --exclude=README.md --exclude=readme.md --exclude=.gitignore

How to exclude a specific file or folder

You can usersync-options and pass in as many--exclude options as you want. By default this action excludes github files. If you choose to customizersync-options make sure you copy over the defaults.

Example excluding all.jpg files:

rsync-options: --exclude "*.jpg"

Example excluding a specific folder:

rsync-options: --exclude "wp-content/themes/"


Common Errors

rsync not found. Please seehttps://github.com/SamKirkland/web-deploy#rsync-not-installed

This library usesrsync to sync files. The script was not able to detectrsync on the machine running the action.If you are usingruns-on: ubuntu-latest you will always haversync.

If you are usingwindows-latest,windows-XXXX,macos-latest,macos-12 or aself-hosted runner you will need to install rsync before theweb-deploy step.

This is pretty easy to do!

Onwindows runners run your windows specific steps, then use aubuntu-latest step to deploy.

On self-hosted runners install rsyncbefore theweb-deploy step.

runs-on:[self-hosted, linux, my-self-hosted-runner-label]steps:    -name:Install rsyncrun:|        sudo apt-get update        sudo apt-get install rsync

Onmacos runners install rsyncbefore theweb-deploy step.

runs-on:macos-lateststeps:    -name:Install rsyncrun:|        brew update        brew install rsync

Read more about customizing runners

https://docs.github.com/en/actions/using-github-hosted-runners/customizing-github-hosted-runners


web deploy anything is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.

About

Deploy websites via sftp/ssh/rsync
v1
Latest

web deploy anything is not certified by GitHub. It is provided by a third-party and is governed by separate terms of service, privacy policy, and support documentation.


[8]ページ先頭

©2009-2025 Movatter.jp