This GitHub action copies the files via FTP from your Git project to your server in a specific path.
By default, ftp_ssl_allow is set to true so lftp tries to encrypt the connection (it falls back to cleartext if the server refuses; use ftps:// or lftp_settings: "set ftp:ssl-force true;" to require TLS), and ssl_verify_certificate is also set to true, so the action refuses to connect to a server with an invalid, expired, or hostname-mismatched certificate. This is a breaking change from v1.x: if you connect to a server with a self-signed certificate or a direct IP, the action will now fail with a TLS error. To opt back into the v1.x behaviour, set ssl_verify_certificate: false explicitly in your workflow.
Note on direct-IP connections: lftp cannot validate a hostname against an IP-address certificate, so
ssl_verify_certificate: truerequires both a valid certificate and a hostname (not a bare IP) in theserverinput.
The action supports both plain FTP and FTPS, and FTPS has two
distinct flavours. The choice is driven by the URL scheme in the
server input and the ftp_ssl_allow toggle. Picking the
wrong combination is the most common cause of "the action worked
yesterday on a different FTP" reports.
server scheme |
ftp_ssl_allow |
What you get | Default port |
|---|---|---|---|
ftp://host |
true (default) |
Explicit FTPS (RFC 4217). Plain TCP connect, then lftp sends AUTH TLS to upgrade the control channel (without waiting for the server's FEAT list, because the ftp_use_feat input defaults to false), then PROT P for data. The upgrade is opportunistic: if the server, or a network attacker, refuses AUTH TLS, lftp continues in cleartext and sends the password unprotected. To require TLS, use ftps:// or add lftp_settings: "set ftp:ssl-force true;". This is the default and the most common deployment. |
21 |
ftp://host |
false |
Plain FTP. Password and file contents are sent in clear. Only use this on a trusted LAN. | 21 |
ftps://host |
true (default) |
Implicit FTPS (RFC 1738). TLS from the very first byte — the server's welcome banner is already inside TLS. Most legacy "FTPS" hosting providers (and many Windows-IIS setups) speak this. | 990 |
ftps://host |
false |
Inconsistent — lftp will still try to negotiate TLS because the URL scheme is ftps://. The action exits with a protocol error. The ftp_ssl_allow input is effectively ignored when the scheme is ftps://. |
990 |
The two ssl:verify-certificate and ssl:check-hostname settings
apply to every row above except the plain-FTP one (which has no
TLS handshake to verify). For the ftps:// rows, lftp also honours
ftps:initial-prot (C, S, E, P, or empty) — leave it at the
default "" unless the server has a known PROT-bug workaround;
the action does not set it.
- Modern shared hoster with TLS (most "free" or cheap web
hosts):
ftp://ftp.example.com— the action's default tries explicit FTPS on port 21. Addlftp_settings: "set ftp:ssl-force true;"so a refusedAUTH TLSfails the run instead of falling back to cleartext. - Legacy FTPS host on port 990 (some cPanel / Plesk setups,
many IIS deployments, some European hosters): use
ftps://ftp.example.comorftps://ftp.example.com:990. Leaveftp_ssl_allowat its default. - No TLS at all (in-house FTP, an old NAS): use
ftp://hostand setftp_ssl_allow: "false". You do not need to touchssl_verify_certificate: it is a boolean that defaults totrue, and it has no effect on a plain FTP connection.
Troubleshooting hand-off: if the runner reports
getpeername: Connection refusedonftps://host:990, the server is most likely not an implicit-FTPS server (some providers run explicit-only on 21, others run implicit on 990). Switch the scheme toftp://and the port to21, keepingftp_ssl_allow: "true". See the Troubleshooting table below.
The action negotiates TLS 1.2 at most by default
(tls_max_version: "1.2"). lftp 4.9.3, the FTPS client inside the
action, mishandles TLS 1.3: it closes each data connection without
reading the session tickets the server sent, so the connection is
reset. The server then replies 426 Failure reading network stream.
and may keep a truncated file. lftp reconnects and resumes, so a
deploy either fails or takes many times longer than it should (#361).
Set tls_max_version: "1.3" only if your server refuses TLS 1.2.
Plain FTP (ftp_ssl_allow: "false") is not affected.
Add this code in ./.github/workflows/your_action.yml.
More about GitHub "secrets" in this article: Creating and storing encrypted secrets.
name: CI -> Deploy to My website
on:
push:
branches: [ main, development ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Here is the deployment action
- name: Upload from public_html via FTP
uses: airvzxf/ftp-deployment-action@v4.0.2
with:
server: ${{ secrets.FTP_SERVER }}
user: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local_dir: "./public_html"Pin to a specific tag (recommended): use an exact release such as
@v4.0.2(the examples below use it) or a full commit SHA. Floating refs (@v4,@v3,@v2,@v1,@latest,@main,@master) are not moved by the release pipeline, so they can lag behind the latest release.Verify a tag's signature before pinning to it:
scripts/verify-tag.sh <tag>checks the tag against the allow-lists onorigin/main(for a signed tag it fetchesmainfirst, so it needs network access toorigin, and never makes the clone shallow) and auto-detects whichever backend the tag used (.github/trusted-signersfor SSH-signed tags,.github/trusted-signers.ascfor PGP-signed tags; see SECURITY.md for the per-tag range). The release pipeline'sverify-tag-signaturejob uses the same lists and runs the same check for signed tags on every push before any image is published.
v4.0.0 rejects a remote_dir or concurrency_lock_path that is ~
or starts with ~/; the run fails with exit 2 before it connects.
lftp expands a leading ~ to the FTP login directory, and a relative
path already starts there, so drop the ~/:
# before
remote_dir: "~/public_html"
# after
remote_dir: "public_html"remote_dir: "~" becomes remote_dir: "./". Nothing else changed:
same inputs, same defaults. v3.x is end-of-life; @v3 stays on
v3.1.0. The CHANGELOG lists the fixes in v4.0.0.
v3.0.0 removes one input, fail_on_deprecated. Delete it from your
workflow if you set it, and change the ref:
- uses: airvzxf/ftp-deployment-action@v4.0.2If you leave the input in, GitHub prints an Unexpected input warning
and the deploy runs as before. Nothing else changed: same inputs, same
defaults, same exit codes. v2.x is end-of-life; @v2 stays on v2.12.1.
Nothing to change. FTPS now negotiates TLS 1.2 at most by default; see
TLS version. Set tls_max_version: "1.3" only if your
server refuses TLS 1.2.
v1.x accepted any TLS certificate. Since v2.0.0 ssl_verify_certificate
defaults to true. Plain FTP to an IP address works unchanged. FTPS to
an IP address, or to a server with a self-signed certificate, needs one
extra input:
ssl_verify_certificate: 'false'The @latest tag points to the newest release.
Every tag is published to two registries by default (ghcr.io + Docker Hub when configured); a third (ECR Public) is currently disabled — see below:
| Registry | Image | How to consume |
|---|---|---|
| GitHub Container Registry (default) | ghcr.io/airvzxf/ftp-deployment-action:v4.0.2 |
uses: airvzxf/ftp-deployment-action@v4.0.2 (the example above) |
| Docker Hub | docker.io/airvzxf/ftp-deployment-action:v4.0.2 |
uses: docker://docker.io/airvzxf/ftp-deployment-action:v4.0.2 |
Both carry the same OCI image bytes (one docker buildx build,
one digest), the same cosign keyless signature, and the same CycloneDX SBOM
attestation (attached via actions/attest). ghcr.io is always
published; Docker Hub is conditional on the repo having the
right secrets configured (see the Maintainer setup
section below). If the Docker Hub secrets are missing, the
release pipeline emits a ::notice:: and skips that registry —
the v2.9.0 behaviour (ghcr.io only) is preserved bit-for-bit.
To verify the signature, use cosign v3 or later. The release
pipeline signs with cosign v3, which stores the signature in the
new bundle format, and cosign v2 reports no signatures found.
cosign verify \
--certificate-identity "https://github.com/airvzxf/ftp-deployment-action/.github/workflows/release.yml@refs/tags/v4.0.2" \
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
ghcr.io/airvzxf/ftp-deployment-action:v4.0.2
gh attestation verify oci://ghcr.io/airvzxf/ftp-deployment-action:v4.0.2 --owner airvzxfNote on ECR Public: A third registry (
public.ecr.aws/m2z1h0m9/...) exists for enterprise visibility but is currently disabled — the AWS IAM role's OIDC trust policy is no longer aligned with this repo, and the maintainer does not currently have access to the AWS account. Therelease.ymlECR Public steps are commented out (not deleted) so re-enabling is a one-line change in two places when the trust policy is fixed. See the "Re-enable ECR Public" section below for the exact diff.
This is a one-time setup. It is not required to use the action; it is only required if you are the maintainer pushing new releases.
Docker Hub (publishes to docker.io/airvzxf/ftp-deployment-action):
- Create a Docker Hub Personal Access Token (PAT) at https://hub.docker.com/settings/security (read + write + delete is fine; we only push).
- Add two repository secrets on
https://github.com/airvzxf/ftp-deployment-action/settings/secrets/actions:
DOCKERHUB_USERNAME— your Docker Hub username (the namespace owner; for this repo, that isairvzxf).DOCKERHUB_TOKEN— the PAT from step 1.
- Tag and push the next release. The pipeline will detect both secrets and push to docker.io alongside ghcr.io.
Skipping a registry: leave its secrets unset. The pipeline
emits a ::notice:: and falls back to the registries that do
have secrets configured. The ghcr.io path is unaffected.
ECR Public publishing is disabled by default. All four ECR
Public sites in .github/workflows/release.yml are under
# DISABLED: preambles:
- The ECR Public block inside the
Resolve tag, version and enabled registriesstep (metastep in thebuildjob) — guarded byif [ -n "${ECR_DISABLED_FORCE:-}" ] && [ -n "${AWS_ROLE_TO_ASSUME}" ], so the publish path is only taken when both are set. When the condition is false, the step emitsecr_enabled=falseand a::notice::explaining why the publish was skipped. - The two ECR Public login steps (
Configure AWS credentials (OIDC) for ECR PublicandLog in to ECR Public) further down in thebuildjob — commented out, with a# DISABLED:preamble referencing the meta-step block above. - The cosign-sign ECR branch in the
Sign image with cosignstep — wrapped inif [ "${{ steps.meta.outputs.ecr_enabled }}" = "true" ], which is dead whileecr_enabled=false. - The
Attach SBOM attestation to ECR Public imagestep at the end of thebuildjob — commented out, with a# DISABLED:preamble.
To re-enable, do three things (canonical runbook tracked in #212):
- Repair the AWS IAM role's OIDC trust policy documented in
the next section so this repo can assume it, and set the
AWS_ROLE_TO_ASSUMErepository secret to the repaired role ARN. - Uncomment the three commented-out ECR steps in
.github/workflows/release.yml(the two ECR login steps inbuildand theAttach SBOM attestation to ECR Public imagestep at the end ofbuild). Theif [ ... = "true" ]wrapping on the cosign-sign ECR branch is already in place; it becomes live the momentecr_enabledflips totrue. - For a one-off test run that bypasses the IAM trust policy
state (e.g. to validate the OIDC + ECR Public path
end-to-end before the trust policy is repaired), set the
ECR_DISABLED_FORCErepository variable to any non-empty string (e.g.1) on https://github.com/airvzxf/ftp-deployment-action/settings/variables/actions. WithECR_DISABLED_FORCEnon-empty ANDAWS_ROLE_TO_ASSUMEset, the meta step takes the publish branch unconditionally and emitsecr_enabled=true— useful for end-to-end testing on a temporary fork. Remove the variable once the IAM trust policy is confirmed working — leaving it set forces every future release to publish to ECR Public regardless of the IAM state, which is rarely what you want.
The meta step's ECR_DISABLED_FORCE opt-in is the only
release.yml line you can flip without editing the file.
The three commented-out steps (login ×2 + SBOM attestation)
must be uncommented by hand. After both edits, future
releases will start publishing to ECR Public without further
in-source changes.
The original setup (kept here so re-enabling does not require re-deriving the IAM policy from scratch):
ECR Public (publishes to
public.ecr.aws/m2z1h0m9/ftp-deployment-action — no static AWS
secrets):
-
Create an ECR Public repository in the AWS account you want to publish from. The repository name must be
ftp-deployment-action(the URL becomespublic.ecr.aws/<registry-id>/ftp-deployment-action, where<registry-id>is the account-specific registry ID AWS assigns automatically — e.g.m2z1h0m9for this account). AWS does not let you set a custom registry ID: it is derived from your AWS Account ID and is permanent for the account. -
Create an IAM role with the following trust policy (replace
ACCOUNT_IDwith your 12-digit AWS account ID):{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Federated": "arn:aws:iam::ACCOUNT_ID:oidc-provider/token.actions.githubusercontent.com" }, "Action": "sts:AssumeRoleWithWebIdentity", "Condition": { "StringEquals": { "token.actions.githubusercontent.com:aud": "sts.amazonaws.com" }, "StringLike": { "token.actions.githubusercontent.com:sub": "repo:airvzxf/ftp-deployment-action:ref:refs/tags/v*" } } } ] }The
subcondition pins the role to tag pushes only of this repo — pull requests andworkflow_dispatchruns from forks cannot assume it. -
Attach an inline policy granting the minimum ECR Public perms:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ecr-public:GetAuthorizationToken" ], "Resource": "*" }, { "Effect": "Allow", "Action": [ "ecr-public:BatchCheckLayerAvailability", "ecr-public:PutImage", "ecr-public:InitiateLayerUpload", "ecr-public:UploadLayerPart", "ecr-public:CompleteLayerUpload" ], "Resource": "arn:aws:ecr-public::ACCOUNT_ID:repository/ftp-deployment-action" } ] } -
Add one repository secret:
AWS_ROLE_TO_ASSUME— the role ARN from step 2 (e.g.arn:aws:iam::ACCOUNT_ID:role/ftp-deployment-action-publisher). -
Tag and push the next release. The pipeline will assume the role via OIDC (
aws-actions/configure-aws-credentials@v4) and login withaws-actions/amazon-ecr-login@v2. No static AWS access keys are stored in the repo.
Skipping a registry: leave its secrets unset. The pipeline
emits a ::notice:: and falls back to the registries that do
have secrets configured. The ghcr.io path is unaffected.
Usually the zero values mean unlimited or infinite. This table is based on the default values on lftp-4.9.3.
Boolean inputs accept a fixed spelling set. Every input whose default is
true/false(delete,no_symlinks,ftp_ssl_allow,ssl_verify_certificate,ssl_check_hostname,ftp_passive_mode,ftp_use_feat,debug,dry_run,concurrency_lock) accepts the case-sensitive settrue,false,yes,no,on,off,0, and1. Anything else — including capitalised variants such asTrue,YES, orOn— is rejected with exit code2before the upload starts.Numeric inputs reject leading zeros.
max_retries,mirror_verbose,ftp_nop_interval,net_max_retries,net_persist_retries,net_timeout,dns_max_retries,dns_fatal_timeout,concurrency_lock_timeout, andconcurrency_lock_poll_intervalaccept a non-negative integer without leading zeros (concurrency_lock_poll_intervalmust also be greater than0).max_retries: "00"(and any other0-prefixed integer) exits2rather than being silently treated as0. The same guard applies to the two duration inputs (net_timeout,dns_fatal_timeout):net_timeout: "00s"anddns_fatal_timeout: "00"are rejected with exit2— they are silent typos of the0retry-forever sentinel, not distinct values.
| Option | Description | Required | Default | Example |
|---|---|---|---|---|
| server | FTP server: ftp://host[:port] or ftps://host[:port] (implicit TLS); a bare host[:port] means ftp://. IPv6 in brackets (ftp://[2001:db8::1]:21). No user:pass@, with or without a scheme (exit 2): use user / password. The target directory is remote_dir, not the URL path. |
Yes | N/A | rovisoft.net |
| user | FTP Username. | Yes | N/A | myself@rovisoft.net |
| password | FTP Password. | Yes | N/A | ExampleOnlyAlphabets |
| local_dir | Local directory. Must not be, contain or lie inside /home/lftp (see Security). |
No | "./" | "./public_html" |
| remote_dir | Remote directory. Must not be ~ or start with ~/ (lftp expands a leading ~ to the FTP login directory; exit 2). |
No | "./" | "/www/user/home" |
| max_retries | Number of tries on error; 1 = no retries. 0 = retry until success, a permanent error, or the job is stopped (set timeout-minutes). Each attempt is limited to 5 h. |
No | 10 | N/A |
| delete | Delete remote files that do not exist locally (files matching exclude are kept). |
No | false | N/A |
| no_symlinks | Do not create symbolic links. | No | true | N/A |
| mirror_verbose | Mirror verbosity: 0 (quiet) to 3 (most verbose); higher values behave like 3. | No | 1 | N/A |
| ftp_ssl_allow | FTP - Try explicit TLS on ftp://; falls back to cleartext if refused. See Security and SSL. |
No | true | N/A |
| ssl_verify_certificate | FTP - Verify SSL certificate. | No | true | N/A |
| ssl_check_hostname | FTP - Check certificate hostname. | No | true | N/A |
| tls_max_version | Highest TLS version for FTPS: 1.2 or 1.3. See TLS version. |
No | 1.2 | N/A |
| ftp_passive_mode | FTP - This can be useful if you are behind a firewall or a dumb masquerading router. | No | true | N/A |
| ftp_use_feat | FTP - FEAT: Determining what extended features the FTP server supports. With true and ftp_ssl_allow true, lftp tries TLS only if the FEAT reply lists AUTH TLS. |
No | false | N/A |
| ftp_nop_interval | FTP - Delay in seconds between NOOP commands when downloading tail of a file. | No | 2 | N/A |
| net_max_retries | NET - Maximum number of operation without success. 0 unlimited. 1 no retries. |
No | 1 | N/A |
| net_persist_retries | NET - Retries of hard (5xx) errors; 0 reports them at once. | No | 0 | N/A |
| net_timeout | NET - Sets the network protocol timeout. | No | 15s | N/A |
| dns_max_retries | DNS - 0 no limit trying to lookup an address otherwise try only this number of times. | No | 8 | N/A |
| dns_fatal_timeout | DNS - Time for DNS queries. Set to "never" to disable. |
No | 10s | N/A |
| lftp_settings | Any other settings that you find in the MAN pages for the LFTP package. At most 3 ; characters are accepted (a trailing ; counts; && does not). Trusted input: it can run shell commands and read the FTP credentials, so never pass it untrusted values (see Security). |
No | "" | "set cache:cache-empty-listings true; set cmd:status-interval 1s; set http:user-agent 'firefox';" |
| exclude | Comma-separated shell globs. Matching files are not uploaded and not deleted. | No | "" | "*.map, *.bak, node_modules/" |
| debug | If "true", print the resolved value of every input to the log. With "false" the dump prints only "(set)" (non-empty value, defaults included) or "(using default)" (empty) per input. The password is never printed, even with debug. | No | false | N/A |
| dry_run | If "true", compute the mirror plan but do not transfer or delete any file. It still connects and logs in, so an unreachable server or a wrong password fails. | No | false | N/A |
| concurrency_lock | If "true", serialize concurrent deployments to the same FTP server by acquiring a server-side sentinel directory. See "Concurrency / deployment lock" below. | No | false | N/A |
| concurrency_lock_path | Path of the sentinel directory used by concurrency_lock. Must be a valid FTP path (no .., no shell metacharacters, no leading dash, no !, no ", no space, no >, ', or \, and not ~ or a path that starts with ~/). |
No | .lftp-deployment.lock | N/A |
| concurrency_lock_timeout | Maximum seconds to wait for the lock when concurrency_lock is "true" and another run is currently holding it. 0 means fail immediately when held or when the sentinel upload fails. |
No | 300 | N/A |
| concurrency_lock_poll_interval | Seconds between lock acquisition attempts; must be greater than 0 (empty means 5). The number of attempts depends on concurrency_lock_timeout, which is wall-clock time. |
No | 5 | N/A |
How
ftp_ssl_allowinteracts with theserverURL scheme. The defaultftp_ssl_allow: "true"only takes effect when theserverinput uses theftp://scheme (explicit FTPS, port 21). If you point the action at an implicit-FTPS server withftps://host:990, lftp speaks TLS regardless offtp_ssl_allow, and setting it to"false"actually breaks the connection. See the "Plain FTP vs FTPS" table in Security and SSL for the full matrix.
More information on the official site for lftp - Manual pages.
Only server, user and password are required. All other settings, including
local_dir (default ./), use the defaults shown in the table above. The
Usage Example sets local_dir only to upload ./public_html
instead of the workspace root. For full control see the extended example below.
name: CI -> Deploy to My website
on:
push:
branches: [ main, development ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Here is the deployment action
- name: Upload from public_html via FTP
uses: airvzxf/ftp-deployment-action@v4.0.2
with:
server: ${{ secrets.FTP_SERVER }}
user: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local_dir: "./public_html"
remote_dir: "/www/sub-domain/games/myself"
delete: "true"
max_retries: "7"
no_symlinks: "false"
ftp_ssl_allow: "false"
ssl_verify_certificate: "true"
ssl_check_hostname: "false"
tls_max_version: "1.2"
ftp_use_feat: "true"
ftp_nop_interval: "9"
net_max_retries: "3"
net_persist_retries: "0"
net_timeout: "13s"
dns_max_retries: "17"
dns_fatal_timeout: "never"
lftp_settings: "set cache:cache-empty-listings true; set cmd:status-interval 1s; set http:user-agent 'firefox';"
exclude: "*.map, *.bak, node_modules/"
dry_run: "false"exclude is a comma-separated list of shell globs, for example
"*.map, *.bak, node_modules/". Spaces around the commas are
ignored. Each glob is passed to lftp as one mirror -X <glob>
option, so every matching file or directory, at any depth, is
neither uploaded nor deleted. With delete: "true", this is how
you protect server-only files such as logs or user uploads.
Each glob must not start with - or contain a space, a backslash (\),
a single quote (') or a greater-than sign (>); the whole value
must not contain control characters, newlines, ;, &, | or ".
Otherwise the action exits with code 2 before connecting.
Two workflows (or two runs of the same workflow) deploying to
the same FTP server at the same time can corrupt each
other: lftp mirror --reverse lists both source and target
directories, then races on writes. Concurrent uploads with
--delete are especially dangerous — each run can see the
other's freshly-uploaded files and delete them as "no longer
in the source".
If both deployments run in the same workflow (or in two
workflows you control), the simplest fix is GitHub's built-in
serialization. Add a concurrency: group to your job:
jobs:
deploy:
runs-on: ubuntu-latest
concurrency:
group: ftp-deploy-${{ github.ref }}
cancel-in-progress: false
steps:
- uses: airvzxf/ftp-deployment-action@v4.0.2
with:
server: ${{ secrets.FTP_SERVER }}
user: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}group: ftp-deploy-${{ github.ref }}— at most one deploy per ref (branch / tag) at a time. Useftp-deploy-${{ github.workflow }}-${{ github.ref }}if you also want to serialize across distinct workflows that deploy to the same server.cancel-in-progress: false— newer runs wait for the in-flight one to finish instead of cancelling it (which would leave a half-uploaded server).
This works across runners, regions, and self-hosted hosts, and requires no code in the action. It is the recommended option for everyone who can set it.
If you cannot add a concurrency: block (e.g. your deploy is
driven by a tool you don't own, or you deploy from multiple
distinct workflows pointing to the same FTP and don't want
to share a group name), opt in to the server-side lock:
- uses: airvzxf/ftp-deployment-action@v4.0.2
with:
server: ${{ secrets.FTP_SERVER }}
user: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
concurrency_lock: "true"What it does. Before the mirror, lftp issues the
high-level mkdir <path> command to create a sentinel
directory on the FTP server. If the server replies 257
(created), the deployment holds the lock and proceeds.
If mkdir fails (normally a 550, the directory already
exists), another run is in flight; the action polls up to
concurrency_lock_timeout seconds (retrying every
concurrency_lock_poll_interval seconds) and then fails
with a clear error. When the run ends (success, error,
the 5-hour timeout, or a HUP, INT or TERM signal), the
EXIT trap deletes this run's sentinel and issues
rmdir <path> to release the lock. A signal during the mirror
stops lftp at once; the lock is released after lftp has
exited, and the action exits 129, 130 or 143 (HUP,
INT, TERM). A signal during another step takes effect
when that step ends: after at most 30 seconds for an
lftp call of the lock code (lock acquire, sentinel
refresh), at most 45 seconds for the retry backoff, or
one concurrency_lock_poll_interval while waiting for
the lock. A signal during the lock mkdir is handled
when the mkdir returns, before the action knows whether
it created the dir, so nothing is released: a lock dir
created by that mkdir stays without a sentinel and is
taken over by the stale-lock recovery below after 120
seconds. A signal after a successful mkdir, the
sentinel upload included, releases the lock (DELE of
the sentinel, then rmdir) once that step ends. If the
sentinel upload fails, the action removes the dir itself
(DELE, then rmdir) before it polls again, and a
signal from then on until its next successful mkdir
releases nothing: the dir is already gone or, if that
rmdir was refused, stays without a sentinel (see the
stale-lock recovery below). SIGKILL runs no
cleanup, so if the runtime kills the container first
(docker stop sends SIGKILL 10 seconds after SIGTERM)
the lock is left to the stale-lock recovery below. Which
signal a GitHub Actions cancel sends to the container,
and how long before SIGKILL, is up to the runner and not
verified here.
A wrong password or an unreachable server fails at once. The
action reads lftp's mkdir output. A login failure
(mkdir: Login failed: 530 ...) or a connection failure
(Connection refused, an unknown host, a connect timeout) is not a
held lock: the action exits 1 right away with
ERROR: concurrency lock: lftp could not log in to <server> (or
could not connect to <server>), followed by lftp's error line,
without polling. A rejected TLS certificate
(mkdir: Fatal error: Certificate verification: ...) fails the same
way, with could not verify the TLS certificate of <server>. Any
other mkdir failure, including a 421 or 530 connection limit
that lftp gave up retrying, counts as "lock held" and is polled as
before.
The lock's lftp calls (mkdir, the sentinel upload and refresh, the
release) connect with the same ftp_ssl_allow,
ssl_verify_certificate, ssl_check_hostname, passive-mode and
lftp_settings values as the mirror; only their retry and timeout
settings are shorter.
Why MKD/RMD and not a "lock" command. lftp does not
ship a server-side lock primitive — it only has
file:use-lock for local files. MKD and RMD are RFC 959
basics and are implemented by every FTP server
(vsftpd, proftpd, Pure-FTPd, SFTP-via-FTP-gateways, etc.).
mkdir is atomic on virtually every UNIX-like filesystem
(returning EEXIST if the dir already exists), so two clients
cannot both create the lock dir.
Taking over an orphaned lock is not atomic. When a lock is
orphaned (a sentinel older than 6 hours, or a lock dir that a
waiting run has seen without a sentinel for 120 seconds), two
waiting runs can both try to recover it: one run's recovery
rmdir can remove the other's new lock dir in the short gap
between that run's mkdir and its sentinel upload. Usually that
run's sentinel upload then fails and it waits again. If its
upload is delayed until the other run has waited one
concurrency_lock_poll_interval and created its own lock dir,
the upload lands there and both runs hold the lock. The
120-second wait is timed per run; it restarts when the run sees
a sentinel or after its own takeover attempt, but not when the
dir is re-created by someone else. This needs an orphaned lock
plus a waiter whose poll lands in another run's
mkdir-to-upload gap, so it is rare. The action does not
close it, because an atomic way to publish the lock would differ
per FTP server. For guaranteed serialization use Option A
above (the concurrency: block).
A live holder keeps the lock; a dead one is recovered after
6 hours. When the action acquires the lock it also writes a
timestamp-encoded sentinel file inside the lock dir, e.g.
.lftp-deployment.lock/.lftp-deployment.lock.20260707T080000Z.1234.info
(stamp and runner PID). Only that lock dir's own sentinel counts,
so different concurrency_lock_path values never affect each
other, and RMD of the dir fails while a sentinel is still in it.
Before every mirror attempt, the first one included, the holder
renames its sentinel to the current stamp (lftp mv, an atomic
FTP RNFR/RNTO, so the sentinel is never missing). One attempt
is capped at 5 hours (plus a 30-second kill), so as long as the
renames succeed, the stamp of a live run is never 6 hours old,
even on a self-hosted runner whose job runs longer than 6 hours
or with max_retries: "0". If a rename fails, the action prints
a warning and goes on with the old sentinel; the deploy does not
fail, but once that sentinel is 6 hours old a waiting run can
take the lock over. The sentinel's content
(started_at=) keeps the acquire time; only the file name counts.
A runner that finds the lock held reads that stamp:
- Sentinel younger than 6 hours: the holder may still be
mirroring (a large deploy can take longer than
concurrency_lock_timeout), so the lock is respected. The runner polls up toconcurrency_lock_timeoutseconds and then fails with exit 1 and an error that names the lock and the sentinel. - Sentinel older than 6 hours: the holder has not refreshed
its sentinel (once per mirror attempt) for 6 hours, so that run
is gone (runner OOM,
kill -9). The runnerDELEs the sentinel,RMDs the lock dir, waitsconcurrency_lock_poll_intervalseconds and takes the lock. - Lock dir without a sentinel: the holder may be between its
mkdirand the sentinel upload (at most 30 seconds), or it died there. The runner treats the lock as held and takes it over only after it has seen the dir without a sentinel for 120 seconds in a row, then waitsconcurrency_lock_poll_intervalseconds before it retriesmkdir.
Sentinel upload failure. If mkdir succeeds but the sentinel
upload into the lock dir fails (quota, write permission, a file
name the server refuses), the runner deletes the partial sentinel
and the dir, waits concurrency_lock_poll_interval seconds and
tries again until concurrency_lock_timeout; with
concurrency_lock_timeout: "0" it fails at once. If the last
attempt failed this way, the action exits 1 with
ERROR: lock dir <path> was created but the sentinel upload to <path>/<sentinel> failed; check write permission and quota under concurrency_lock_path instead of saying that another deployment is
in progress.
A lock dir that cannot be removed. On a server that allows
mkdir but refuses RMD (or when the RMD fails for another
reason), the cleanup after a failed sentinel upload, or the takeover
of a lock dir without a sentinel, leaves the dir in place. The
runner then exits 1 with ERROR: lock dir <path> exists without a sentinel and could not be removed (RMD refused or failed). Remove <path> on the server by hand, or check the server's delete permission under concurrency_lock_path. The run whose upload failed
adds the lock dir <path> could not be removed either to its upload
error. A later run only tries the takeover after 120 seconds, so it
needs a concurrency_lock_timeout longer than that to report this;
with a shorter timeout (or "0") it reports another deployment in
progress. The release at the end of a run uses lftp's rmdir as
well: if that RMD is refused or fails, or the dir is not empty
(a sentinel DELE was refused too), the run keeps its exit code
(0 after a successful deploy) and the log ends with
::warning::concurrency lock: could not remove the lock dir <path> after the run (lftp exit <n>: RMD refused or failed, or the dir is not empty), followed by what later runs will report and how to fix
it. A DELE of a sentinel name that never existed on the server
fails harmlessly and causes no warning when the RMD works.
If a holder died less than 6 hours ago, the next deploys fail with that error until you clear the lock. Delete the two entries the error names, for example:
lftp -u user ftp://example.com \
-e "quote DELE .lftp-deployment.lock/.lftp-deployment.lock.<stamp>.<pid>.info; \
quote RMD .lftp-deployment.lock; quit;"Customizing the lock path. If you have several deployments against the same FTP server (e.g. one for production, one for staging, each writing to a different remote directory), give each its own lock path:
- uses: airvzxf/ftp-deployment-action@v4.0.2
with:
concurrency_lock: "true"
concurrency_lock_path: ".lftp-deployment.lock.prod"Limitations.
- The lock is advisory: a hostile client that ignores the sentinel can still upload concurrently. The lock protects against accidental races from CI runs, not against malicious actors.
- The lock is per-server, not per-path: two deploys to
the same FTP but different
remote_dirwill serialize. This is usually the right call (uploads to the same server still share an FTP control connection and the server's filesystem cache) but if you need finer granularity, give each deploy a differentconcurrency_lock_path. - The lock is not replicated across FTP servers: if you
mirror to two backends via different
serverinputs in one step, this input does not coordinate between them. For that, use Option A with a sharedconcurrency:group.
+--------------------------+
| GitHub Actions runner |
| invokes the action |
+------------+-------------+
|
v
+--------------------------+
| entrypoint.sh starts |
| (sources /app/lib.sh) |
| |
| 1. Mask sensitive |--- ::add-mask:: password / user / server
| inputs (add_masks) |
| |
| 2. Validate inputs |--- path traversal? shell metachars? --> exit 2
| (validate_int, |
| validate_path, |
| validate_lftp_ |
| settings) |
| |
| 3. Build FTP_SETTINGS |--- one 'set foo bar' per input
| + MIRROR_COMMAND | (build_ftp_settings / build_mirror_command)
| + normalize paths |
| |
| 4. Write .netrc |--- 0600, removed by EXIT trap
| (write_netrc) |
| |
| 4b. Acquire server lock |--- only if concurrency_lock=true
| (acquire_lock_with_ | high-level `mkdir <path>`; checks for
| recovery) | sentinels older than 6 h; polls up to
| | concurrency_lock_timeout s
| | then fails with exit 1
| |
| 5. lftp -e "..." |--- +5h timeout per attempt
| (run_lftp_once + | + exponential backoff with jitter
| retry loop, | + per-attempt net/dns timeouts
| max_retries=0..N) | + releases lock via `rmdir` + EXIT trap
| | if it was acquired
| |
| 6. Result banner |--- ERROR: UPLOAD FAILED + last lftp exit code
| (print_failure_ | FTP UPLOADED FINISHED! on success
| banner / print_ | FTP DRY RUN COMPLETED on dry run
| success_banner) |
+------------+-------------+
|
v
+--------------------------+
| PASS -> exit 0 |
| FAIL -> exit 1 |
| INPUT -> exit 2 |
+--------------------------+
Main features:
- Copy all the files inside the specific folder from your GitHub repository to the specific folder in your server.
- Option to delete remote files that no longer exist in the local folder.
- Using Alpine container means small size and faster creation of the container.
- Show messages in the console logs for every executed command.
# Lint (shellcheck + actionlint + hadolint) and run the smoke tests
make lint
make test
# Build a local image and run the release smoke checks against it
make build IMAGE=ftp-deployment-action:local
make release-smoke IMAGE=ftp-deployment-action:localmake build runs docker build and
make release-smoke runs the same two checks the release
workflow runs against the just-pushed image:
- The container starts and
validate_pathrejects a..path-traversal inlocal_dirwith exit 2. - The first line of a run is
ftp-deployment-action vX.Y.Z(the repo'sVERSIONfile, copied into the image).
These checks catch the kind of regression that broke the v2.3.0 release (Dependabot bumped the alpine base image, the lftp package pin became unresolvable, the v2.3.0 tag was cut with a non-buildable image) before a tag is pushed.
| Code | Meaning |
|---|---|
0 |
Upload finished successfully. |
1 |
Upload failed after all retries; the last lftp error is printed above. |
2 |
Invalid input. This includes: a server URL that fails the path / metacharacter guard, or that embeds a password in the userinfo (ftp://user:pass@host or user:pass@host — the userinfo password is rejected); a local_dir / remote_dir / concurrency_lock_path that fails the path-traversal, shell-metacharacter, or ASCII-space guard; a remote_dir or concurrency_lock_path that contains >, \ or ' (they are pasted unquoted into lftp commands), or that is ~ or starts with ~/; a local_dir that is, contains, or lies inside /home/lftp, or that contains \ or starts with ~ or file:; a non-integer numeric option or one with a leading zero (e.g. max_retries: "00"); a boolean option outside the canonical set (see the Settings preamble); an lftp_settings value that contains control characters, a backtick, a dollar sign, the literal ! character, an embedded newline, or more than three ; characters (a trailing ; counts); a concurrency_lock_poll_interval of 0 when concurrency_lock is true; an exclude value rejected by validate_glob_pattern (control chars, ;, &, ` |
lftp's own output (transferred files, the dry_run plan, server errors) is
printed in the step log; there is nothing else to download.
Each lftp attempt is capped at 5 hours. When an attempt hits the cap, the lftp
process is killed and the attempt counts as one of the max_retries tries like
any other failure (it is not a permanent error; with max_retries: "0" it is
retried until the job is stopped). After the last try the action exits with
1 and prints the most recent lftp exit code for debugging. The image uses busybox timeout, so that lftp exit code is
143 (SIGTERM at the 5-hour cap), or 137 if lftp was still running 30 s later
and got SIGKILL; it is never GNU timeout's 124.
| Symptom in the log | Likely cause | Fix |
|---|---|---|
530 Login authentication failed |
Wrong user / password, or the account is locked. |
Verify the credentials against the server with an FTP client (e.g. lftp -u user,pass host). Make sure the secret in the repo is the one you think it is. |
550 Permission denied on every file |
The FTP user can read/write remote_dir but cannot enter the parent, or delete: true is trying to remove files it does not own. |
Try a fresh remote_dir you have full control over (e.g. /www/...). If you only need upload without delete, leave delete: false. |
Fatal error: certificate verify failed (TLS) |
The server uses a self-signed certificate, the cert is expired, or you are connecting to a bare IP. | ssl_verify_certificate is true by default since v2.0.0. If you trust the server, set ssl_verify_certificate: "false" explicitly. For a bare IP you cannot validate a hostname — use a hostname with a real cert or opt out. |
Connection refused / hangs on connect |
Wrong host/port, firewall blocking outbound 21/990, or the FTP server is down. | Verify server (ftp://host:21 or ftps://host:990). From the runner, nc -vz host 21 should succeed. Some shared hosters block the runner's IP range — ask them to allow-list it. |
Fatal error: max-retries exceeded with no reason in parentheses, and the banner says lftp got no reply from the server |
The connection never got an FTP greeting: a firewall drops the packets, the host or port is wrong, or the server closes the connection before replying. Each try waits for net_timeout, so the step looks like a slow loop of the same message. |
Same checks as Connection refused. GitHub-hosted runners connect from Azure IP ranges: hosters and VPS firewalls often block them, so allow-list the range or use a self-hosted runner. To see each connect attempt and its timeout, add lftp_settings: "debug 3;" for one run. |
another deployment is currently in progress after waiting concurrency_lock_timeout, while no other job is running |
With concurrency_lock: "true", a lock mkdir failure other than a login or connection error (those fail at once with could not log in to / could not connect to) is treated as the lock being held: a live holder's sentinel, a lock dir left without a sentinel that this run did not try to remove (it waits 120 seconds first), or an unrecognised server reply. |
See Concurrency / deployment lock for clearing a stale lock. A lock dir without a sentinel is removed only after 120 seconds, so use a concurrency_lock_timeout above that. |
lock dir <path> exists without a sentinel and could not be removed |
The server refused (or failed) the RMD of the lock dir, after a failed sentinel upload or during a takeover. |
Remove the dir by hand (quote RMD <path>) and give the FTP user delete permission under concurrency_lock_path. |
mirror: Access failed: 550 ... No such file or directory |
The remote path does not exist or the FTP user has no permission to create it. | Create the remote_dir manually (or set delete: false and accept a partial mirror) and confirm the FTP user owns it. |
mirror: <path>: Permission denied or mirror: Access failed: <path>: Permission denied, with no 550 |
The <path> is a local path under local_dir, unlike the remote 550 rows above. The action runs as the unprivileged lftp user and cannot read a file or directory that is not world-readable (for example after umask 077, files written 0600 by a root step, or a mktemp -d directory). lftp uploads the other files, then exits 1. The action does not treat this as permanent, so it retries until max_retries runs out. |
Add a step before the action: chmod -R a+rX <local_dir> (files o+r, directories o+rx). See Self-hosted runners. |
getpeername: Connection refused on ftps://host:990 |
The server is not speaking implicit FTPS — it is almost certainly explicit FTPS on port 21. The ftps:// URL forces TLS from byte 0, which the server rejects. |
Switch server to ftp://host:21 and keep ftp_ssl_allow: "true". See the "Plain FTP vs FTPS" table in Security and SSL. |
426 Failure reading network stream. after STOR, file size increased during transfer, or an FTPS deploy that is slow and reconnects every few files |
The server negotiated TLS 1.3, which lftp 4.9.3 mishandles at the end of each upload (#361). | Keep tls_max_version at its default "1.2". If you set "1.3", remove it. |
lftp logs PROT command not understood then drops the data connection |
Some legacy FTPS servers do not support PROT P even though they accept AUTH TLS. lftp falls back to PROT C (clear data channel) by default; if the server closes the data connection instead, the action exits 1. |
Add lftp_settings: "set ftps:initial-prot C;" to the step, or ask the hoster to enable PROT P server-side. |
can't create /<some-path>/.netrc: Permission denied (or Read-only file system) on self-hosted runners |
The runner is forwarding its host HOME into the container. The action tried to write <HOME>/.netrc, but the directory is read-only or owned by a different uid than the in-container lftp user. |
entrypoint.sh pins NETRC=/home/lftp/.netrc and export HOME=/home/lftp regardless of any inherited HOME, so this error means an image older than v2.11.0: pin a current release. See Self-hosted runners below for the full picture. |
The job is still running for hours:
lftpis probably waiting on a half-open TCP connection. Since v1.5.0 the action wraps every lftp attempt in a hard 5-hourtimeout; a stuck attempt is killed at that point and counts as one of themax_retriestries, and the action exits1after the last one. The job'stimeout-minutes(360 by default on GitHub-hosted runners) usually ends the run first when several attempts hang. If you want to fail faster, setnet_timeout/dns_fatal_timeoutlower than the defaults (15s/10s).
The action is a Docker action — it is forwards-compatible with
any Linux runner that ships a recent Docker or Podman (GitHub-hosted
ubuntu-latest, self-hosted Linux containers, k8s pods). macOS
and Windows runners are not supported for container actions;
runners that wrap a non-Linux container engine (Apple Colima,
Rancher Desktop) are out of scope because the image we build is
linux/amd64 Alpine (see Dockerfile).
Self-hosted runners forward environment variables from the host
into the container by default. In practice this means HOME is
copied from the runner process, which is usually /github/home
(the GitHub Actions Runner service) or /home/runner (bare-metal).
The action ignores the inherited HOME and pins HOME=/home/lftp
unconditionally — entrypoint.sh writes the credentials to
/home/lftp/.netrc (the path the Dockerfile guarantees to be
writable for the lftp user), so the deployment succeeds even
when the host HOME is read-only or owned by a different uid.
The action runs as the unprivileged lftp user (a system user created
with adduser -S; the Dockerfile sets no fixed uid, so do not rely on a
particular number). Every file and directory under local_dir must
therefore be readable by "other": files o+r, directories o+rx. The
exception is an entry owned by the lftp uid itself, which is not the
case for anything a normal workflow step writes. If an entry is not
readable, lftp prints mirror: <path>: Permission denied or
mirror: Access failed: <path>: Permission denied, uploads the rest
and exits 1; the action treats this as a transient error and retries
the whole run until max_retries is used up (with max_retries: "0",
until the job is stopped). Typical causes are a build
step that runs with umask 077, files written 0600 by a step that
runs as root in a container, and a mktemp -d directory (0700).
GitHub-hosted checkouts are normally world-readable already; this
mostly bites self-hosted runners and generated build output. The
directories above local_dir need o+x as well, which the chmod
below does not change; the workspace root normally has it. Fix it
with a step before the action:
- name: Make the build output readable by the action
run: chmod -R a+rX ./public_html
- name: Deploy
uses: airvzxf/ftp-deployment-action@v4.0.2
with:
server: ${{ secrets.FTP_SERVER }}
user: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local_dir: "./public_html"See also SECURITY.md → "Self-hosted runners" for the security
implications of environment forwarding and how the action's
.netrc path pin keeps the password out of argv in every
configuration.
For how to report vulnerabilities please see SECURITY.md.
This action runs as the unprivileged lftp user inside the container
(Dockerfile USER lftp). The password input is never passed to
lftp on the command line: it is written to ~/.netrc with mode
0600 for the duration of the run and removed via an EXIT trap on
success, error and set -e abort, and on HUP, INT or TERM, whose
traps exit through it (during the mirror at once, otherwise when the
current step ends, after at most 30 seconds, 45 seconds in the retry
backoff, or one lock poll interval). SIGKILL runs no trap; the file
then stays in the container's own filesystem (/home/lftp is not a
host mount) until the container is removed. Combined, these mean the
password never appears in /proc/<pid>/cmdline or in the GitHub
Actions runner log.
server, local_dir, remote_dir, and concurrency_lock_path
are all validated against the same deny-list: .. path-traversal
components, leading dashes (which lftp would misread as options),
control characters, newlines, double quotes, shell metacharacters
(;, &, |, backtick, and dollar), ! (lftp's shell escape),
and ASCII space — a value like /my data/site/ exits 2
instead of silently breaking the lftp -e tokeniser.
remote_dir and concurrency_lock_path are pasted into their
lftp commands without surrounding quotes, so they additionally
reject >, \ and ': lftp 4.9.3 reads > as an output
redirection (even mid-token, so a>x uploads to a and drops
the rest), \ as an escape and ' as a quote, each of which
changes which directory the command uses (FND-0100). They
also exit 2 when the value is ~ or starts with ~/: lftp
4.9.3 expands a leading ~ in these commands to the FTP login
directory (mkdir ~ sends MKD for the login directory itself,
so the lock could never be taken). Use a relative path instead,
which already starts at the login directory. ~name, a~b and
x/~ reach the server as written and are accepted. The
server input additionally rejects URL userinfo that embeds a
password (the ftp://user:pass@host form — lftp would otherwise
authenticate with the embedded credentials and silently bypass
the action's documented credential source).
local_dir must also stay out of the action's home directory
/home/lftp, which holds the .netrc with the password while the
mirror runs. A local_dir that is /home/lftp, lies inside it, or
contains it (/, /home) exits 2, because the reverse mirror
would upload the .netrc to remote_dir. Relative values are
resolved against the job workspace (/github/workspace), and
repeated or trailing slashes do not matter. The check is lexical:
it does not follow symlinks, so do not point a symlink in the
workspace at /home/lftp. The action passes local_dir to lftp
in double quotes, so characters such as ', > or # are part of
the path. A local_dir that contains a backslash (\), starts with
~ or starts with file: exits 2, because lftp reads \ as an
escape character inside the quotes, expands ~ to the action's
home and reads file: as a local file URL.
lftp_settings is trusted input. Its value runs as lftp
commands inside the container, and lftp commands can run shell
commands and read the FTP credentials, so setting it is equivalent
to running commands in the container with access to the password.
Never pass it values from untrusted sources (reusable-workflow
inputs, matrix values or PR data you do not control). The action
rejects control characters, newlines, backtick, dollar, ! and
more than three ; characters, but these checks
only catch mistakes; they are not a security boundary (pipes,
source -e and even a plain set cmd:at-exit ... still run shell
commands).
The exclude input uses a separate validate_glob_pattern
validator because its globs are passed to the lftp mirror command.
It rejects control characters, newlines and command-separator
characters (;, &, |, and "), and any glob that starts with a
dash or contains a space, a backslash, a single quote or a > (lftp's
escape, quote and output-redirection characters could make the paths
after the glob part of it, or drop the mirror's directory arguments so
it uploads the working directory), while allowing glob metacharacters such as
!, backticks, and $. The action exits with code 2 and a clear
error when validation fails.
See CHANGELOG.md for release notes.