mirror of
https://github.com/cross-the-world/scp-pipeline.git
synced 2025-09-10 11:39:52 +08:00
parse env in path/ try copy . in local
This commit is contained in:
20
.github/workflows/deploy.yml
vendored
20
.github/workflows/deploy.yml
vendored
@@ -4,6 +4,9 @@ on:
|
||||
branches:
|
||||
- master
|
||||
|
||||
env:
|
||||
TARGET_DIR: /home/github/test
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build
|
||||
@@ -24,10 +27,10 @@ jobs:
|
||||
local: './test/*'
|
||||
remote: /home/github/test/
|
||||
scp: |
|
||||
'./test/test*.csv' => "/home/github/test/test2/"
|
||||
'.' => /home/github/test/
|
||||
'./test/test*.csv' => "$TARGET_DIR/test2/"
|
||||
'.' => $TARGET_DIR
|
||||
|
||||
- name: local remote scp
|
||||
- name: local remote scp 1
|
||||
uses: cross-the-world/scp-pipeline@master
|
||||
with:
|
||||
host: ${{ secrets.DC_HOST }}
|
||||
@@ -35,3 +38,14 @@ jobs:
|
||||
pass: ${{ secrets.DC_PASS }}
|
||||
local: "./test/test1*"
|
||||
remote: /home/github/test/test1/
|
||||
|
||||
- name: local remote scp 2
|
||||
uses: cross-the-world/scp-pipeline@master
|
||||
env:
|
||||
TO_DIR: /home/github/test/test3/
|
||||
with:
|
||||
host: ${{ secrets.DC_HOST }}
|
||||
user: ${{ secrets.DC_USER }}
|
||||
pass: ${{ secrets.DC_PASS }}
|
||||
local: "."
|
||||
remote: $TO_DIR
|
||||
|
13
app.py
13
app.py
@@ -37,12 +37,12 @@ def convert_to_seconds(s):
|
||||
strips = [" ", "\"", " ", "'", " "]
|
||||
|
||||
|
||||
def strip_path(p):
|
||||
def strip_and_parse_envs(p):
|
||||
if not p:
|
||||
return None
|
||||
for c in strips:
|
||||
p = p.strip(c)
|
||||
return p
|
||||
return path.expandvars(p)
|
||||
|
||||
|
||||
def connect():
|
||||
@@ -69,14 +69,17 @@ def scp_process():
|
||||
|
||||
copy_list = []
|
||||
if INPUT_LOCAL and INPUT_REMOTE:
|
||||
copy_list.append({"l": INPUT_LOCAL, "r": INPUT_REMOTE})
|
||||
copy_list.append({
|
||||
"l": strip_and_parse_envs(INPUT_LOCAL),
|
||||
"r": strip_and_parse_envs(INPUT_REMOTE)
|
||||
})
|
||||
for c in INPUT_SCP.splitlines():
|
||||
if not c:
|
||||
continue
|
||||
l2r = c.split("=>")
|
||||
if len(l2r) == 2:
|
||||
local = strip_path(l2r[0])
|
||||
remote = strip_path(l2r[1])
|
||||
local = strip_and_parse_envs(l2r[0])
|
||||
remote = strip_and_parse_envs(l2r[1])
|
||||
if local and remote:
|
||||
copy_list.append({"l": local, "r": remote})
|
||||
continue
|
||||
|
Reference in New Issue
Block a user