This repository was archived by the owner on Oct 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcopy4GIT.yaml
More file actions
49 lines (43 loc) · 1.64 KB
/
copy4GIT.yaml
File metadata and controls
49 lines (43 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Author : Nuno Aguiar
# How to run : ojob copy4GIT.yaml COPY4GIT_TARGET=/some/dir/data COPY4GIT_URL=https://github.com/openaf/openaf.git
# Other variables: COPY4GIT_TEMP, COPY4GIT_BRANCH, COPY4GIT_USER, COPY4GIT_PASS
ojob:
argsFromEnvs: true
logToConsole: false
todo:
- name: Init
- name: Copy repository
###########################################################
# The code
jobs:
# Initialize global variables
- name: Init
exec: |
global.target = _$(args.COPY4GIT_TARGET).default("/data");
global.giturl = _$(args.COPY4GIT_GITURL).$_("You need to provide a COPY4GIT_GITURL.");
global.temp = _$(args.COPY4GIT_TEMP).default(global.target + ".tmp");
log("Checking temp and target folders...");
io.mkdir(global.target);
io.mkdir(global.temp);
if (io.fileExists(global.temp + "/.git")) {
logErr("The temp folder can't have an active GIT repository.");
throw "The temp folder can't have an active GIT repository.";
}
# Copy repository
- name: Copy repository
deps:
- Init
exec: |
plugin("GIT");
try {
var git = new GIT();
log("Retriving '" + global.giturl + "' to '" + global.temp + "' temporary folder...");
git.clone(global.giturl, global.temp, false, void 0, global.COPY4GIT_BRANCH, global.COPY4GIT_USER, global.COPY4GIT_PASS);
log("Preparing target folder '" + global.target + "'...");
io.rm(global.target);
io.rm(global.temp + "/.git");
io.mv(global.temp, global.target);
log("Repository copy done.");
} catch(e) {
logErr("Problem copying repository: " + String(e));
}