add command option

This commit is contained in:
your username 2020-04-30 18:52:35 +02:00
parent 3f7edaa478
commit 014f2fcb17
5 changed files with 12 additions and 4 deletions

View File

@ -52,10 +52,11 @@ I recommend you store your `ftp-password` as a secret.
| `ftp-username` | Yes | username@samkirkland.com | | FTP account username |
| `ftp-password` | Yes | CrazyUniquePassword&%123 | | FTP account password |
| `local-dir` | No | deploy/ | ./ | Which local folder to deploy, path should be relative to the root and should include trailing slash. `./` is the root of the project |
| `git-ftp-command` | No | See `git-ftp-command` below | | defaults to push but use any other init, catchup etc. Use catchup to save action minutes first time |
| `git-ftp-args` | No | See `git-ftp-args` section below | | Custom git-ftp arguments, this field is passed through directly into the git-ftp script |
| `known-hosts` | No | hostname ssh-rsa AAAAB3NzaC1y ... | | The desired contents of your .ssh/known_hosts file. See [known hosts setup](#known-hosts-setup) |
#### Advanced options using `git-ftp-args`
#### Advanced options using `git-ftp-command` and `git-ftp-args`
Custom arguments, this field is passed through directly into the git-ftp script. See [git-ftp's manual](https://github.com/git-ftp/git-ftp/blob/master/man/git-ftp.1.md) for all options.
You can use as many arguments as you want, seperate them with a space

View File

@ -15,6 +15,10 @@ inputs:
description: 'The local folder to copy, defaults to root project folder'
defaults: ./
required: false
git-ftp-command:
description: 'if you need to do anything else than push. ie catchup '
defaults: push
required: false
git-ftp-args:
description: 'Passes through options into git-ftp'
defaults:

3
dist/index.js vendored
View File

@ -708,6 +708,7 @@ function getUserArguments() {
ftp_username: core.getInput("ftp-username", { required: true }),
ftp_password: core.getInput("ftp-password", { required: true }),
local_dir: withDefault(core.getInput("local-dir"), "./"),
gitFtpCommand: withDefault(core.getInput("git-ftp-command"), "push"),
gitFtpArgs: withDefault(core.getInput("git-ftp-args"), ""),
knownHosts: withDefault(core.getInput("known-hosts"), "")
};
@ -725,7 +726,7 @@ function syncFiles(args) {
return __awaiter(this, void 0, void 0, function* () {
try {
yield core.group("Uploading files", () => __awaiter(this, void 0, void 0, function* () {
return yield exec.exec(`git ftp push --force --auto-init --verbose --syncroot ${args.local_dir} --user ${args.ftp_username} --passwd ${args.ftp_password} ${args.gitFtpArgs} ${args.ftp_server}`);
return yield exec.exec(`git ftp ${args.gitFtpCommand} --force --auto-init --verbose --syncroot ${args.local_dir} --user ${args.ftp_username} --passwd ${args.ftp_password} ${args.gitFtpArgs} ${args.ftp_server}`);
}));
}
catch (error) {

View File

@ -50,6 +50,7 @@ function getUserArguments(): IActionArguments {
ftp_username: core.getInput("ftp-username", { required: true }),
ftp_password: core.getInput("ftp-password", { required: true }),
local_dir: withDefault(core.getInput("local-dir"), "./"),
gitFtpCommand: withDefault(core.getInput("git-ftp-command"), "push"),
gitFtpArgs: withDefault(core.getInput("git-ftp-args"), ""),
knownHosts: withDefault(core.getInput("known-hosts"), "")
};
@ -69,7 +70,7 @@ function withDefault(value: string, defaultValue: string) {
async function syncFiles(args: IActionArguments) {
try {
await core.group("Uploading files", async () => {
return await exec.exec(`git ftp push --force --auto-init --verbose --syncroot ${args.local_dir} --user ${args.ftp_username} --passwd ${args.ftp_password} ${args.gitFtpArgs} ${args.ftp_server}`);
return await exec.exec(`git ftp ${args.gitFtpCommand} --force --auto-init --verbose --syncroot ${args.local_dir} --user ${args.ftp_username} --passwd ${args.ftp_password} ${args.gitFtpArgs} ${args.ftp_server}`);
});
}
catch (error) {

View File

@ -8,6 +8,7 @@ export interface IActionArguments {
/** @default "" */
gitFtpArgs: string | undefined;
gitFtpCommand: string | undefined;
/** @default "" */
knownHosts: string | undefined;