Compare commits

2 Commits

Author SHA1 Message Date
Sam Kirkland
8e81b13788 v3.1.0-patch
Patch v3.1.0 to resolve wrong git-ftp version being used
2022-12-15 09:52:21 -06:00
Sam Kirkland
50505ea27c switching to debian:10-slim 2021-08-16 11:39:19 -05:00
7 changed files with 54 additions and 100 deletions

View File

@@ -1,12 +1,12 @@
FROM alpine:3.11
FROM debian:stable-slim
LABEL repository="https://github.com/SamKirkland/FTP-Deploy-Action"
LABEL maintainer="Sam Kirkland <FTP-Deploy-Action@samkirkland.com>"
RUN apk --no-cache add curl bash git nodejs libssh2-dev build-base
RUN curl https://raw.githubusercontent.com/git-ftp/git-ftp/1.6.0/git-ftp > /bin/git-ftp
RUN chmod 755 /bin/git-ftp
RUN apt-get update
RUN apt-get install -y git
RUN apt-get install -y git-ftp
RUN apt-get install -y nodejs
COPY dist/index.js /deploy.js
RUN chmod +x deploy.js

View File

@@ -23,7 +23,7 @@ jobs:
with:
fetch-depth: 2
- name: FTP-Deploy-Action
uses: SamKirkland/FTP-Deploy-Action@3.1.2
uses: SamKirkland/FTP-Deploy-Action@3.1.0
with:
ftp-server: ftp://ftp.samkirkland.com/
ftp-username: myFtpUserName
@@ -55,14 +55,14 @@ Keys can be added directly to your .yml config file or referenced from your proj
To add a `secret` go to the `Settings` tab in your project then select `Secrets`.
I recommend you store your `ftp-password` as a secret.
| Key Name | Required? | Example | Default | Description |
|----------------|-----------|--------------------------------------------|---------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `ftp-server` | Yes | ftp://ftp.samkirkland.com/destinationPath/ | | Deployment destination server & path. Formatted as `protocol://domain.com:port/destinationPath/` protocol can be `ftp`, `ftps`, or `sftp`. Port is optional, when not specified it will default to 21 when using ftp, 22 when using sftp, and 990 when using ftps |
| `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-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) |
| Key Name | Required? | Example | Default | Description |
|----------------|-----------|-----------------------------------------------|---------|----------------------------------------------------------|
| `ftp-server` | Yes | ftp://ftp.samkirkland.com/destinationPath/ | | Deployment destination server & path. Formatted as `protocol://domain.com:port/destinationPath/` protocol can be `ftp`, `ftps`, or `sftp`. Port is optional, when not specified it will default to 21 when using ftp, 22 when using sftp, and 990 when using ftps |
| `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-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`
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.
@@ -70,18 +70,18 @@ You can use as many arguments as you want, seperate them with a space
Below is an incomplete list of commonly used args:
| Argument | Description |
|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `--dry-run` | Does not upload or delete anything, but tries to get the .git-ftp.log file from remote host |
| `--silent` | Be silent |
| `--all` | Transfer all files, even seemingly the same as the target site (default is differences only). Note: Only files committed to github are uploaded, if you'd like to upload files generated during the action run see `.git-ftp-include` |
| `--lock` | Locks remote files from being modified while a deployment is running |
| `--remote-root` | Specifies the remote root directory to deploy to. The remote path in the URL is ignored |
| `--key` | SSH private key file name for SFTP |
| `--branch` | Push a specific branch. I recommend [creating a yaml action for each branch instead](https://github.com/SamKirkland/FTP-Deploy-Action/issues/37#issuecomment-579819486) |
| `--pubkey` | SSH public key file name. Used with `--key` option |
| `--insecure` | Don't verify server's certificate |
| `--cacert <file>` | Use as CA certificate store. Useful when a server has a self-signed certificate |
| Argument | Description |
|------------------------|------------------------------------------------------------------------------------------------------|
| `--dry-run` | Does not upload or delete anything, but tries to get the .git-ftp.log file from remote host |
| `--silent` | Be silent |
| `--all` | Transfer all files, even seemingly the same as the target site (default is differences only). Note: Only files committed to github are uploaded, if you'd like to upload files generated during the action run see `.git-ftp-include` |
| `--lock` | Locks remote files from being modified while a deployment is running |
| `--remote-root` | Specifies the remote root directory to deploy to. The remote path in the URL is ignored |
| `--key` | SSH private key file name for SFTP |
| `--branch` | Push a specific branch. I recommend [creating a yaml action for each branch instead](https://github.com/SamKirkland/FTP-Deploy-Action/issues/37#issuecomment-579819486) |
| `--pubkey` | SSH public key file name. Used with `--key` option |
| `--insecure` | Don't verify server's certificate |
| `--cacert <file>` | Use as CA certificate store. Useful when a server has a self-signed certificate |
### Ignore specific files when deploying
Add patterns to `.git-ftp-ignore` and all matching file names will be ignored. The patterns are interpreted as shell glob patterns.
@@ -183,7 +183,7 @@ jobs:
with:
fetch-depth: 2
- name: FTP-Deploy-Action
uses: SamKirkland/FTP-Deploy-Action@3.1.2
uses: SamKirkland/FTP-Deploy-Action@3.1.0
with:
ftp-server: ftp://ftp.samkirkland.com/
ftp-username: myFtpUserName
@@ -212,7 +212,7 @@ jobs:
fetch-depth: 2
- name: FTP-Deploy-Action
uses: SamKirkland/FTP-Deploy-Action@3.1.2
uses: SamKirkland/FTP-Deploy-Action@3.1.0
with:
ftp-server: ftps://ftp.samkirkland.com:21/
ftp-username: myFTPSUsername
@@ -259,7 +259,7 @@ jobs:
fetch-depth: 2
- name: FTP-Deploy-Action
uses: SamKirkland/FTP-Deploy-Action@3.1.2
uses: SamKirkland/FTP-Deploy-Action@3.1.0
with:
ftp-server: sftp://ftp.samkirkland.com:7280/
ftp-username: mySFTPUsername
@@ -284,10 +284,10 @@ jobs:
with:
fetch-depth: 2
- name: Use Node.js 16
uses: actions/setup-node@v2
- name: Use Node.js 12.x
uses: actions/setup-node@v1
with:
node-version: '16'
node-version: '12.x'
- name: Build Project
run: |
@@ -298,7 +298,7 @@ jobs:
run: ls
- name: FTP-Deploy-Action
uses: SamKirkland/FTP-Deploy-Action@3.1.2
uses: SamKirkland/FTP-Deploy-Action@3.1.0
with:
ftp-server: ftp://ftp.samkirkland.com/
ftp-username: myFTPUsername
@@ -321,7 +321,7 @@ jobs:
fetch-depth: 2
- name: FTP-Deploy-Action
uses: SamKirkland/FTP-Deploy-Action@3.1.2
uses: SamKirkland/FTP-Deploy-Action@3.1.0
with:
ftp-server: ftp://ftp.samkirkland.com/
ftp-username: myFTPUsername
@@ -418,24 +418,14 @@ jobs:
---
## Debugging locally
##### Instructions for debugging Windows
- [Install docker](https://docs.docker.com/get-docker/)
- Open powershell **as Administrator**
- Install [act-cli](https://github.com/nektos/act#installation) by running `choco install act-cli`
##### Instructions for debugging on windows
- Install docker for windows
- Open powershell
- Navigate to the repo folder
- Run `npm install` - this will install all dependencies to build this project
- Run `npm build` - this will build the action javascript and watch/rebuild when files change
- Run `npm run build-docker` - this will build the docker container (only needs to be done once)
- Run `npm run run-docker` - this will spin up a local copy of the action defined in `/debug/local-debug-deployment.yaml`. Update package.json to set any secret values
- Run `docker build --tag action .`
- Run `docker run action`
#### Instructions for debugging on Linux
- [Install docker](https://docs.docker.com/get-docker/) on a Debian-based distro you can run `sudo apt install docker docker.io`
- Open the terminal
- Install [act-cli](https://github.com/nektos/act#installation)
- Navigate to the repo folder
- Run `npm install` - this will install all dependencies to build this project
- Run `npm build` - this will build the action javascript and watch/rebuild when files change
- Run `npm run build-docker` - this will build the docker container (only needs to be done once)
- Run `npm run run-docker` - this will spin up a local copy of the action defined in `/debug/local-debug-deployment.yaml`. Update package.json to set any secret values
##### Instructions for debugging on linux
- Please submit a PR for linux instructions :)
#### Pull Requests Welcome!

View File

@@ -1,18 +0,0 @@
on: push
name: Local Debug Deployment
jobs:
Local-Debug-Deployment:
name: Local-Debug-Deployment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2.1.0
with:
fetch-depth: 2
- name: FTP-Deploy-Action
uses: ./
with:
ftp-server: ftp://ftp.samkirkland.com/
ftp-username: ${{ secrets.username }}
ftp-password: ${{ secrets.password }}
git-ftp-args: --dry-run

12
dist/index.js vendored
View File

@@ -1049,19 +1049,11 @@ 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 push --force --auto-init --verbose --syncroot ${args.local_dir} --user ${args.ftp_username} --passwd ${args.ftp_password} ${args.gitFtpArgs} ${args.ftp_server}`);
}));
}
catch (error) {
console.error("⚠️ Failed to upload files");
core.setFailed(error.message);
}
});

View File

@@ -1,16 +1,17 @@
{
"name": "typescript-action",
"version": "3.1.2",
"version": "1.0.0",
"private": true,
"description": "TypeScript template action",
"main": "dist/main.js",
"engines": {
"node": ">=16.0.0"
"node": ">=12.0.0"
},
"scripts": {
"build": "ncc build src/main.ts -o dist --watch",
"build-docker": "docker build --tag action .",
"run-docker": "act --workflows ./debug/ --secret username=UserNameHere --secret password=PasswordHere"
"build:dev": "tsc",
"build:production": "ncc build src/main.ts -o dist",
"build:docker": "docker build --tag action .",
"run:docker": "docker run action --build-arg FTP_SERVER=example.com FTP_USERNAME=test@example.com FTP_PASSWORD=passwordExample"
},
"repository": {
"type": "git",

View File

@@ -70,22 +70,11 @@ 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 push --force --auto-init --verbose --syncroot ${args.local_dir} --user ${args.ftp_username} --passwd ${args.ftp_password} ${args.gitFtpArgs} ${args.ftp_server}`);
});
}
catch (error) {
console.error("⚠️ Failed to upload files");
core.setFailed(error.message);
}
}

View File

@@ -25,7 +25,7 @@ export enum gitFTPExitCode {
ErrorWhileDownloading = 5,
UnknownProtocol = 6,
RemoteLocked = 7,
GitRelatedError = 8,
NotAGitProject = 8,
PreFTPPushHookFailed = 9,
LocalFileOperationFailed = 10
}