mirror of
https://github.com/SamKirkland/FTP-Deploy-Action.git
synced 2025-08-15 06:25:05 +00:00
Ignore .github folder by default
The `.github` folder is now excluded from the sync by default. The reason for this change is that the `.github` folder often includes sensitive information used for deployment configuration. This behavior can be overwritten by setting the `include-github` input to `true`.
This commit is contained in:
parent
3f7edaa478
commit
6c02cac4ac
@ -54,6 +54,7 @@ I recommend you store your `ftp-password` as a secret.
|
|||||||
| `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) |
|
||||||
|
| `ignore-github` | No | false | true | Ignore the `.github` folder when deploying. For security reasons, the `.github`-folder is excluded from the deployed files per default |
|
||||||
|
|
||||||
#### 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.
|
||||||
|
@ -15,6 +15,10 @@ inputs:
|
|||||||
description: 'The local folder to copy, defaults to root project folder'
|
description: 'The local folder to copy, defaults to root project folder'
|
||||||
defaults: ./
|
defaults: ./
|
||||||
required: false
|
required: false
|
||||||
|
ignore-github:
|
||||||
|
description: 'Whether the .github directory should be excluded from synchronization'
|
||||||
|
default: "true"
|
||||||
|
required: false
|
||||||
git-ftp-args:
|
git-ftp-args:
|
||||||
description: 'Passes through options into git-ftp'
|
description: 'Passes through options into git-ftp'
|
||||||
defaults:
|
defaults:
|
||||||
|
20
src/main.ts
20
src/main.ts
@ -5,12 +5,14 @@ import { promisify } from 'util';
|
|||||||
import { IActionArguments } from './types';
|
import { IActionArguments } from './types';
|
||||||
|
|
||||||
const writeFileAsync = promisify(fs.writeFile);
|
const writeFileAsync = promisify(fs.writeFile);
|
||||||
|
const appendFileAsync = promisify(fs.appendFile);
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const userArguments = getUserArguments();
|
const userArguments = getUserArguments();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await configureHost(userArguments);
|
await configureHost(userArguments);
|
||||||
|
await excludeGithub(userArguments);
|
||||||
await syncFiles(userArguments);
|
await syncFiles(userArguments);
|
||||||
|
|
||||||
console.log("✅ Deploy Complete");
|
console.log("✅ Deploy Complete");
|
||||||
@ -33,7 +35,7 @@ async function configureHost(args: IActionArguments): Promise<void> {
|
|||||||
|
|
||||||
await exec.exec(`mkdir -v -p ${sshFolder}`);
|
await exec.exec(`mkdir -v -p ${sshFolder}`);
|
||||||
await exec.exec(`chmod 700 ${sshFolder}`);
|
await exec.exec(`chmod 700 ${sshFolder}`);
|
||||||
writeFileAsync(`${sshFolder}/known_hosts`, args.knownHosts);
|
await writeFileAsync(`${sshFolder}/known_hosts`, args.knownHosts);
|
||||||
await exec.exec(`chmod 755 ${sshFolder}/known_hosts`);
|
await exec.exec(`chmod 755 ${sshFolder}/known_hosts`);
|
||||||
|
|
||||||
console.log("✅ Configured known_hosts");
|
console.log("✅ Configured known_hosts");
|
||||||
@ -44,6 +46,19 @@ async function configureHost(args: IActionArguments): Promise<void> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function excludeGithub(args: IActionArguments) {
|
||||||
|
if (args.ignoreGithub?.toLowerCase() != "true") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
await appendFileAsync(".git-ftp-ignore", "\n.github");
|
||||||
|
} catch (error) {
|
||||||
|
console.error("⚠️ Error adding .github-folder to .git-ftp-ignore", error);
|
||||||
|
core.setFailed(error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
function getUserArguments(): IActionArguments {
|
function getUserArguments(): IActionArguments {
|
||||||
return {
|
return {
|
||||||
ftp_server: core.getInput("ftp-server", { required: true }),
|
ftp_server: core.getInput("ftp-server", { required: true }),
|
||||||
@ -51,7 +66,8 @@ function getUserArguments(): IActionArguments {
|
|||||||
ftp_password: core.getInput("ftp-password", { required: true }),
|
ftp_password: core.getInput("ftp-password", { required: true }),
|
||||||
local_dir: withDefault(core.getInput("local-dir"), "./"),
|
local_dir: withDefault(core.getInput("local-dir"), "./"),
|
||||||
gitFtpArgs: withDefault(core.getInput("git-ftp-args"), ""),
|
gitFtpArgs: withDefault(core.getInput("git-ftp-args"), ""),
|
||||||
knownHosts: withDefault(core.getInput("known-hosts"), "")
|
knownHosts: withDefault(core.getInput("known-hosts"), ""),
|
||||||
|
ignoreGithub: withDefault(core.getInput("ignore-github"), "true"),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,6 +11,9 @@ export interface IActionArguments {
|
|||||||
|
|
||||||
/** @default "" */
|
/** @default "" */
|
||||||
knownHosts: string | undefined;
|
knownHosts: string | undefined;
|
||||||
|
|
||||||
|
/** @default "true" */
|
||||||
|
ignoreGithub: string | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user