mirror of
https://github.com/SamKirkland/FTP-Deploy-Action.git
synced 2026-04-10 12:32:17 +02:00
Compare commits
20 Commits
v3.1.0-pat
...
v3.1.2-pat
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f5c9578e8 | ||
|
|
0caa4381b6 | ||
|
|
7de54c03c0 | ||
|
|
92c056182f | ||
|
|
422dce0884 | ||
|
|
d3bf065539 | ||
|
|
da9bb5718e | ||
|
|
d944ec5d31 | ||
|
|
fc58a9886b | ||
|
|
1b692c9f5b | ||
|
|
8a8c5e2142 | ||
|
|
bfc8472cf6 | ||
|
|
41575a636c | ||
|
|
4158862244 | ||
|
|
559ddbb4df | ||
|
|
da0d77ff39 | ||
|
|
1af692f7d5 | ||
|
|
ae5262e007 | ||
|
|
b698c49eac | ||
|
|
ccf756b42e |
10
Dockerfile
10
Dockerfile
@@ -1,12 +1,12 @@
|
|||||||
FROM debian:stable-slim
|
FROM alpine:3.11
|
||||||
|
|
||||||
LABEL repository="https://github.com/SamKirkland/FTP-Deploy-Action"
|
LABEL repository="https://github.com/SamKirkland/FTP-Deploy-Action"
|
||||||
LABEL maintainer="Sam Kirkland <FTP-Deploy-Action@samkirkland.com>"
|
LABEL maintainer="Sam Kirkland <FTP-Deploy-Action@samkirkland.com>"
|
||||||
|
|
||||||
RUN apt-get update
|
RUN apk --no-cache add curl bash git nodejs libssh2-dev build-base
|
||||||
RUN apt-get install -y git
|
|
||||||
RUN apt-get install -y git-ftp
|
RUN curl https://raw.githubusercontent.com/git-ftp/git-ftp/1.6.0/git-ftp > /bin/git-ftp
|
||||||
RUN apt-get install -y nodejs
|
RUN chmod 755 /bin/git-ftp
|
||||||
|
|
||||||
COPY dist/index.js /deploy.js
|
COPY dist/index.js /deploy.js
|
||||||
RUN chmod +x deploy.js
|
RUN chmod +x deploy.js
|
||||||
|
|||||||
82
README.md
82
README.md
@@ -23,7 +23,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
- name: FTP-Deploy-Action
|
- name: FTP-Deploy-Action
|
||||||
uses: SamKirkland/FTP-Deploy-Action@3.1.0
|
uses: SamKirkland/FTP-Deploy-Action@3.1.2
|
||||||
with:
|
with:
|
||||||
ftp-server: ftp://ftp.samkirkland.com/
|
ftp-server: ftp://ftp.samkirkland.com/
|
||||||
ftp-username: myFtpUserName
|
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`.
|
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.
|
I recommend you store your `ftp-password` as a secret.
|
||||||
|
|
||||||
| Key Name | Required? | Example | Default | Description |
|
| 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-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-username` | Yes | username@samkirkland.com | | FTP account username |
|
||||||
| `ftp-password` | Yes | CrazyUniquePassword&%123 | | FTP account password |
|
| `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 |
|
| `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 |
|
| `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) |
|
| `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-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.
|
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:
|
Below is an incomplete list of commonly used args:
|
||||||
|
|
||||||
| Argument | Description |
|
| Argument | Description |
|
||||||
|------------------------|------------------------------------------------------------------------------------------------------|
|
|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| `--dry-run` | Does not upload or delete anything, but tries to get the .git-ftp.log file from remote host |
|
| `--dry-run` | Does not upload or delete anything, but tries to get the .git-ftp.log file from remote host |
|
||||||
| `--silent` | Be silent |
|
| `--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` |
|
| `--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 |
|
| `--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 |
|
| `--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 |
|
| `--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) |
|
| `--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 |
|
| `--pubkey` | SSH public key file name. Used with `--key` option |
|
||||||
| `--insecure` | Don't verify server's certificate |
|
| `--insecure` | Don't verify server's certificate |
|
||||||
| `--cacert <file>` | Use as CA certificate store. Useful when a server has a self-signed certificate |
|
| `--cacert <file>` | Use as CA certificate store. Useful when a server has a self-signed certificate |
|
||||||
|
|
||||||
### Ignore specific files when deploying
|
### 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.
|
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:
|
with:
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
- name: FTP-Deploy-Action
|
- name: FTP-Deploy-Action
|
||||||
uses: SamKirkland/FTP-Deploy-Action@3.1.0
|
uses: SamKirkland/FTP-Deploy-Action@3.1.2
|
||||||
with:
|
with:
|
||||||
ftp-server: ftp://ftp.samkirkland.com/
|
ftp-server: ftp://ftp.samkirkland.com/
|
||||||
ftp-username: myFtpUserName
|
ftp-username: myFtpUserName
|
||||||
@@ -212,7 +212,7 @@ jobs:
|
|||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
|
|
||||||
- name: FTP-Deploy-Action
|
- name: FTP-Deploy-Action
|
||||||
uses: SamKirkland/FTP-Deploy-Action@3.1.0
|
uses: SamKirkland/FTP-Deploy-Action@3.1.2
|
||||||
with:
|
with:
|
||||||
ftp-server: ftps://ftp.samkirkland.com:21/
|
ftp-server: ftps://ftp.samkirkland.com:21/
|
||||||
ftp-username: myFTPSUsername
|
ftp-username: myFTPSUsername
|
||||||
@@ -259,7 +259,7 @@ jobs:
|
|||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
|
|
||||||
- name: FTP-Deploy-Action
|
- name: FTP-Deploy-Action
|
||||||
uses: SamKirkland/FTP-Deploy-Action@3.1.0
|
uses: SamKirkland/FTP-Deploy-Action@3.1.2
|
||||||
with:
|
with:
|
||||||
ftp-server: sftp://ftp.samkirkland.com:7280/
|
ftp-server: sftp://ftp.samkirkland.com:7280/
|
||||||
ftp-username: mySFTPUsername
|
ftp-username: mySFTPUsername
|
||||||
@@ -284,10 +284,10 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
|
|
||||||
- name: Use Node.js 12.x
|
- name: Use Node.js 16
|
||||||
uses: actions/setup-node@v1
|
uses: actions/setup-node@v2
|
||||||
with:
|
with:
|
||||||
node-version: '12.x'
|
node-version: '16'
|
||||||
|
|
||||||
- name: Build Project
|
- name: Build Project
|
||||||
run: |
|
run: |
|
||||||
@@ -298,7 +298,7 @@ jobs:
|
|||||||
run: ls
|
run: ls
|
||||||
|
|
||||||
- name: FTP-Deploy-Action
|
- name: FTP-Deploy-Action
|
||||||
uses: SamKirkland/FTP-Deploy-Action@3.1.0
|
uses: SamKirkland/FTP-Deploy-Action@3.1.2
|
||||||
with:
|
with:
|
||||||
ftp-server: ftp://ftp.samkirkland.com/
|
ftp-server: ftp://ftp.samkirkland.com/
|
||||||
ftp-username: myFTPUsername
|
ftp-username: myFTPUsername
|
||||||
@@ -321,7 +321,7 @@ jobs:
|
|||||||
fetch-depth: 2
|
fetch-depth: 2
|
||||||
|
|
||||||
- name: FTP-Deploy-Action
|
- name: FTP-Deploy-Action
|
||||||
uses: SamKirkland/FTP-Deploy-Action@3.1.0
|
uses: SamKirkland/FTP-Deploy-Action@3.1.2
|
||||||
with:
|
with:
|
||||||
ftp-server: ftp://ftp.samkirkland.com/
|
ftp-server: ftp://ftp.samkirkland.com/
|
||||||
ftp-username: myFTPUsername
|
ftp-username: myFTPUsername
|
||||||
@@ -418,14 +418,24 @@ jobs:
|
|||||||
---
|
---
|
||||||
|
|
||||||
## Debugging locally
|
## Debugging locally
|
||||||
##### Instructions for debugging on windows
|
##### Instructions for debugging Windows
|
||||||
- Install docker for windows
|
- [Install docker](https://docs.docker.com/get-docker/)
|
||||||
- Open powershell
|
- Open powershell **as Administrator**
|
||||||
|
- Install [act-cli](https://github.com/nektos/act#installation) by running `choco install act-cli`
|
||||||
- Navigate to the repo folder
|
- Navigate to the repo folder
|
||||||
- Run `docker build --tag action .`
|
- Run `npm install` - this will install all dependencies to build this project
|
||||||
- Run `docker run action`
|
- 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
|
#### Instructions for debugging on Linux
|
||||||
- Please submit a PR for linux instructions :)
|
- [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
|
||||||
|
|
||||||
#### Pull Requests Welcome!
|
#### Pull Requests Welcome!
|
||||||
|
|||||||
18
debug/local-debug-deployment.yaml
Normal file
18
debug/local-debug-deployment.yaml
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
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
12
dist/index.js
vendored
@@ -1049,11 +1049,19 @@ function syncFiles(args) {
|
|||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
yield core.group("Uploading files", () => __awaiter(this, void 0, void 0, function* () {
|
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) {
|
catch (error) {
|
||||||
console.error("⚠️ Failed to upload files");
|
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
11
package.json
11
package.json
@@ -1,17 +1,16 @@
|
|||||||
{
|
{
|
||||||
"name": "typescript-action",
|
"name": "typescript-action",
|
||||||
"version": "1.0.0",
|
"version": "3.1.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "TypeScript template action",
|
"description": "TypeScript template action",
|
||||||
"main": "dist/main.js",
|
"main": "dist/main.js",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=12.0.0"
|
"node": ">=16.0.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:dev": "tsc",
|
"build": "ncc build src/main.ts -o dist --watch",
|
||||||
"build:production": "ncc build src/main.ts -o dist",
|
"build-docker": "docker build --tag action .",
|
||||||
"build:docker": "docker build --tag action .",
|
"run-docker": "act --workflows ./debug/ --secret username=UserNameHere --secret password=PasswordHere"
|
||||||
"run:docker": "docker run action --build-arg FTP_SERVER=example.com FTP_USERNAME=test@example.com FTP_PASSWORD=passwordExample"
|
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
|||||||
15
src/main.ts
15
src/main.ts
@@ -70,11 +70,22 @@ function withDefault(value: string, defaultValue: string) {
|
|||||||
async function syncFiles(args: IActionArguments) {
|
async function syncFiles(args: IActionArguments) {
|
||||||
try {
|
try {
|
||||||
await core.group("Uploading files", async () => {
|
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) {
|
catch (error) {
|
||||||
console.error("⚠️ Failed to upload files");
|
|
||||||
core.setFailed(error.message);
|
core.setFailed(error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -25,7 +25,7 @@ export enum gitFTPExitCode {
|
|||||||
ErrorWhileDownloading = 5,
|
ErrorWhileDownloading = 5,
|
||||||
UnknownProtocol = 6,
|
UnknownProtocol = 6,
|
||||||
RemoteLocked = 7,
|
RemoteLocked = 7,
|
||||||
NotAGitProject = 8,
|
GitRelatedError = 8,
|
||||||
PreFTPPushHookFailed = 9,
|
PreFTPPushHookFailed = 9,
|
||||||
LocalFileOperationFailed = 10
|
LocalFileOperationFailed = 10
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user