feat(action): Create action to deploy with scp command
This commit is contained in:
parent
da262dad45
commit
4aef88179f
4 changed files with 93 additions and 13 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.history
|
||||
.vscode
|
63
README.md
63
README.md
|
@ -1,5 +1,62 @@
|
|||
# Container Action Template
|
||||
# SCP Deploy action
|
||||
|
||||
To get started, click the `Use this template` button on this repository [which will create a new repository based on this template](https://github.blog/2019-06-06-generate-new-repositories-with-repository-templates/).
|
||||
Action to send dist files to a remote server with scp command
|
||||
|
||||
For info on how to build your first Container action, see the [toolkit docs folder](https://github.com/actions/toolkit/blob/master/docs/container-action.md).
|
||||
## Required params
|
||||
|
||||
- `src`: Sorce dir to deploy
|
||||
- `host`: SSH address
|
||||
- `remote`: Remote dir path
|
||||
- `port`: SSH Port
|
||||
- `user`: SSH User name
|
||||
- `key`: Private key
|
||||
|
||||
|
||||
### To publish
|
||||
|
||||
You must generate the ssh key and publish the public pair on your host. On git secrets, publish your private key
|
||||
|
||||
Ex.:
|
||||
|
||||
```bash
|
||||
ssh-keygen -t rsa -b 4096 -f ssh_publish -C <some@name>
|
||||
```
|
||||
|
||||
## Example
|
||||
|
||||
This is a nuxt universal application
|
||||
|
||||
```yml
|
||||
name: MasterCI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
name: Build and Deploy
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@master
|
||||
|
||||
- name: Bucket actions
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: 8
|
||||
- run: npm i
|
||||
- run: npm run test
|
||||
- run: npm run generate
|
||||
|
||||
- name: Publish
|
||||
uses: nogsantos/scp-deploy@master
|
||||
with:
|
||||
src: ./dist/*
|
||||
host: ${{ secrets.SSH_HOST }}
|
||||
remote: ${{ secrets.SSH_DIR }}
|
||||
port: ${{ secrets.SSH_PORT }}
|
||||
user: ${{ secrets.SSH_USER }}
|
||||
key: ${{ secrets.SSH_KEY }}
|
||||
```
|
35
action.yml
35
action.yml
|
@ -1,12 +1,29 @@
|
|||
name: 'Container Action Template'
|
||||
description: 'Get started with Container actions'
|
||||
author: 'GitHub'
|
||||
inputs:
|
||||
myInput:
|
||||
description: 'Input to use'
|
||||
default: 'world'
|
||||
name: 'scp-deploy'
|
||||
description: 'Action to send dist files to a remote server with scp command'
|
||||
author: 'Fabricio Nogueira'
|
||||
inputs:
|
||||
src:
|
||||
description: 'Sorce dir to deploy'
|
||||
required: true
|
||||
host:
|
||||
description: 'SSH address'
|
||||
required: true
|
||||
remote:
|
||||
description: 'Remote dir path'
|
||||
required: true
|
||||
port:
|
||||
description: 'SSH Port'
|
||||
required: false
|
||||
default: 22
|
||||
user:
|
||||
description: 'SSH User name'
|
||||
required: true
|
||||
key:
|
||||
description: 'Private key'
|
||||
required: true
|
||||
runs:
|
||||
using: 'docker'
|
||||
image: 'Dockerfile'
|
||||
args:
|
||||
- ${{ inputs.myInput }}
|
||||
branding:
|
||||
icon: 'upload-cloud'
|
||||
color: 'blue'
|
|
@ -1,3 +1,7 @@
|
|||
#!/bin/sh -l
|
||||
|
||||
echo "hello $1"
|
||||
echo -e "${INPUT_KEY}" >__TEMP_INPUT_KEY_FILE
|
||||
|
||||
chmod 600 __TEMP_INPUT_KEY_FILE
|
||||
|
||||
scp -o StrictHostKeyChecking=no -v -i __TEMP_INPUT_KEY_FILE -P "${INPUT_PORT}" -r ${INPUT_SRC} "${INPUT_USER}"@"${INPUT_HOST}":"${INPUT_REMOTE}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue