2929 'php' : 'php' ,
3030 }
3131
32+ DOCKER_IMAGES = {
33+ 'php' : 'composer' ,
34+ }
35+
36+
37+ def docker_image (lang ):
38+ """you can specify a docker image name for a language,
39+ otherwise the language name will be returned as the image name"""
40+ return DOCKER_IMAGES .get (lang , lang )
41+
3242def run_fun (path , func ):
3343 func_lang = func ['language' ]
3444 if func_lang not in SUPPORTED_LANGS :
@@ -37,6 +47,9 @@ def run_fun(path, func):
3747 if func_file_name .strip () == '' :
3848 return ""
3949
50+ # pre_hook script is a shell script that start with a same name of
51+ # the function file but ends with '.sh',
52+ # will be run before the function running
4053 pre_hook_file = func_file_name + '.sh'
4154 run_pre_hook = '[ -f {0} ] && sh {0} >/dev/null 2>&1' .format (pre_hook_file )
4255
@@ -48,7 +61,7 @@ def run_fun(path, func):
4861
4962 cmd = ['docker' , 'run' , '--rm' , '--workdir' , '/github/workspace' ,
5063 '-v' , os .getenv ('GITHUB_WORKSPACE' ) + ':/github/workspace' ,
51- func_lang + ':latest' , 'sh' , '-c' ,
64+ docker_image ( func_lang ) + ':latest' , 'sh' , '-c' ,
5265 "cd " + path + ";" +
5366 run_pre_hook + ";" +
5467 deps_install .get (func_lang , ':' ) + ";" +
0 commit comments