Skip to content

Commit a62b44d

Browse files
committed
Improve code legibility
1 parent 8fc5a10 commit a62b44d

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
## Usage
88

9+
Please note that if you only specify a single file as source, the target must be a file name and not a folder.
10+
911
### 🔼 Uploading local files to remote target
1012

1113
```yaml
@@ -68,10 +70,8 @@ jobs:
6870
proxy_fingerprint: ${{ secrets.SSH_PROXY_FINGERPRINT }}
6971
proxy_username: ${{ secrets.SSH_USER }}
7072
proxy_key: ${{ secrets.SSH_PRIVATE_KEY }}
71-
source: |
72-
path/to/source/a.txt
73-
path/to/source/b.txt
74-
target: path/to/target
73+
source: path/to/source/a.txt
74+
target: path/to/target/b.txt
7575
```
7676
7777
## Input variables

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ go 1.16
44

55
require (
66
github.com/dtylman/scp v0.0.0-20181017070807-f3000a34aef4
7-
github.com/joho/godotenv v1.3.0
87
github.com/sirupsen/logrus v1.8.1 // indirect
98
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a
109
)

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
22
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
33
github.com/dtylman/scp v0.0.0-20181017070807-f3000a34aef4 h1:Tc//0LMiRsUsOIu4S+HFKleax9X1+3SRKo+36ldZX0c=
44
github.com/dtylman/scp v0.0.0-20181017070807-f3000a34aef4/go.mod h1:jN1ZaUPSNA8jm10nmaRLky84qV/iCeiHmcEf3EbP+dc=
5-
github.com/joho/godotenv v1.3.0 h1:Zjp+RcGpHhGlrMbJzXTrZZPrWj+1vfm90La1wgB6Bhc=
6-
github.com/joho/godotenv v1.3.0/go.mod h1:7hK45KPybAkOC6peb+G5yklZfMxEjkZhHbwpqxOKXbg=
75
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
86
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
97
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=

main.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import (
1212
"golang.org/x/crypto/ssh"
1313

1414
"github.com/dtylman/scp"
15-
"github.com/joho/godotenv"
1615
)
1716

1817
const (
@@ -25,9 +24,6 @@ const (
2524
type copyFunc func(client *ssh.Client, source string, target string) (int64, error)
2625

2726
func main() {
28-
// Make local testing easier.
29-
godotenv.Load()
30-
3127
// Parse timeout.
3228
actionTimeout, err := time.ParseDuration(os.Getenv("ACTION_TIMEOUT"))
3329
if err != nil {
@@ -160,17 +156,21 @@ func Copy(client *ssh.Client) {
160156
}
161157

162158
log.Printf("%s %sing ...\n", emoji, strings.Title(direction))
159+
163160
transferredFiles := int64(0)
164161
if len(sourceFiles) == 1 {
165162
// Rename file if there is only one source file.
166163
if _, err := copy(client, sourceFiles[0], targetFileOrFolder); err != nil {
167164
log.Fatalf("Failed to %s file from remote: %v", os.Getenv("DIRECTION"), err)
168165
}
169166
log.Println(sourceFiles[0] + " >> " + targetFileOrFolder)
167+
168+
log.Println("📡 Transferred 1 file")
170169
} else {
171170
for _, sourceFile := range sourceFiles {
172171
_, file := path.Split(sourceFile)
173172
targetFile := path.Join(targetFileOrFolder, file)
173+
174174
if _, err := copy(client, sourceFile, targetFile); err != nil {
175175
log.Fatalf("Failed to %s file from remote: %v", os.Getenv("DIRECTION"), err)
176176
}
@@ -180,5 +180,5 @@ func Copy(client *ssh.Client) {
180180
}
181181
}
182182

183-
log.Printf("📡 Transferred %d file(s)\n", transferredFiles)
183+
log.Printf("📡 Transferred %d files\n", transferredFiles)
184184
}

0 commit comments

Comments
 (0)