Skip to content

Commit ae5262e

Browse files
committed
using act for local debugging
Added act library for local debugging Attempting to use exec argument escaping
1 parent b698c49 commit ae5262e

File tree

6 files changed

+57
-15
lines changed

6 files changed

+57
-15
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -420,10 +420,13 @@ jobs:
420420
## Debugging locally
421421
##### Instructions for debugging Windows
422422
- [Install docker](https://docs.docker.com/get-docker/)
423-
- Open powershell
423+
- Open powershell **as Administrator**
424+
- Install [act-cli](https://github.com/nektos/act#installation) by running `choco install act-cli`
424425
- Navigate to the repo folder
425-
- Run `docker build --tag action .`
426-
- Run `docker run action`
426+
- Run `npm install` - this will install all dependencies to build this project
427+
- Run `npm build` - this will build the action javascript and watch/rebuild when files change
428+
- Run `npm run build-docker` - this will build the docker container (only needs to be done once)
429+
- 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
427430

428431
#### Instructions for debugging on Linux
429432
- [Install docker](https://docs.docker.com/get-docker/)
@@ -432,8 +435,11 @@ On Linux you can install docker using your package manager, for example, on a De
432435
sudo apt install docker docker.io
433436
```
434437
- Open the terminal
438+
- Install [act-cli](https://github.com/nektos/act#installation)
435439
- Navigate to the repo folder
436-
- Run `docker build --tag action .`
437-
- Run `docker run action`
440+
- Run `npm install` - this will install all dependencies to build this project
441+
- Run `npm build` - this will build the action javascript and watch/rebuild when files change
442+
- Run `npm run build-docker` - this will build the docker container (only needs to be done once)
443+
- 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
438444

439445
#### Pull Requests Welcome!

debug/local-debug-deployment.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on: push
2+
name: Local Debug Deployment
3+
jobs:
4+
Local-Debug-Deployment:
5+
name: Local-Debug-Deployment
6+
runs-on: ubuntu-latest
7+
steps:
8+
- uses: actions/[email protected]
9+
with:
10+
fetch-depth: 2
11+
12+
- name: FTP-Deploy-Action
13+
uses: ./
14+
with:
15+
ftp-server: ftp://ftp.samkirkland.com/
16+
ftp-username: ${{ secrets.username }}
17+
ftp-password: ${{ secrets.password }}
18+
git-ftp-args: --dry-run

dist/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,11 +1049,19 @@ function syncFiles(args) {
10491049
return __awaiter(this, void 0, void 0, function* () {
10501050
try {
10511051
yield core.group("Uploading files", () => __awaiter(this, void 0, void 0, function* () {
1052-
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}`);
1052+
return yield exec.exec("git ftp push", [
1053+
"--force",
1054+
"--auto-init",
1055+
"--verbose",
1056+
`--syncroot=${args.local_dir}`,
1057+
`--user=${args.ftp_username}`,
1058+
`--passwd=${args.ftp_password}`,
1059+
args.gitFtpArgs,
1060+
args.ftp_server
1061+
]);
10531062
}));
10541063
}
10551064
catch (error) {
1056-
console.error("⚠️ Failed to upload files");
10571065
core.setFailed(error.message);
10581066
}
10591067
});

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
"node": ">=12.0.0"
99
},
1010
"scripts": {
11-
"build:dev": "tsc",
12-
"build:production": "ncc build src/main.ts -o dist",
13-
"build:docker": "docker build --tag action .",
14-
"run:docker": "docker run action --build-arg FTP_SERVER=example.com [email protected] FTP_PASSWORD=passwordExample"
11+
"build": "ncc build src/main.ts -o dist --watch",
12+
"build-docker": "docker build --tag action .",
13+
"run-docker": "act --workflows ./debug/ --secret username=UserNameHere --secret password=PasswordHere"
1514
},
1615
"repository": {
1716
"type": "git",

src/main.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,22 @@ function withDefault(value: string, defaultValue: string) {
7070
async function syncFiles(args: IActionArguments) {
7171
try {
7272
await core.group("Uploading files", async () => {
73-
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}`);
73+
return await exec.exec(
74+
"git ftp push",
75+
[
76+
"--force",
77+
"--auto-init",
78+
"--verbose",
79+
`--syncroot=${args.local_dir}`,
80+
`--user=${args.ftp_username}`,
81+
`--passwd=${args.ftp_password}`,
82+
args.gitFtpArgs!,
83+
args.ftp_server!
84+
]
85+
);
7486
});
7587
}
7688
catch (error) {
77-
console.error("⚠️ Failed to upload files");
7889
core.setFailed(error.message);
7990
}
80-
}
91+
}

src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export enum gitFTPExitCode {
2525
ErrorWhileDownloading = 5,
2626
UnknownProtocol = 6,
2727
RemoteLocked = 7,
28-
NotAGitProject = 8,
28+
GitRelatedError = 8,
2929
PreFTPPushHookFailed = 9,
3030
LocalFileOperationFailed = 10
3131
}

0 commit comments

Comments
 (0)