11const core = require ( '@actions/core' ) ;
22const { exec } = require ( '@actions/exec' ) ;
3- const io = require ( '@actions/io' ) ;
43
54
65// gather input
@@ -12,6 +11,7 @@ const fetch = core.getInput('fetch') !== 'false';
1211const holobranch = core . getInput ( 'holobranch' , { required : true } ) ;
1312const lens = core . getInput ( 'lens' ) ;
1413const commitTo = core . getInput ( 'commit-to' , { required : false } ) ;
14+ const cache = core . getInput ( 'cache' ) !== 'false' ;
1515const commitToRef = commitTo
1616 ? (
1717 commitTo == 'HEAD' || commitTo . startsWith ( 'refs/' )
@@ -28,22 +28,21 @@ try {
2828}
2929
3030async function run ( ) {
31- try {
32- await require ( 'habitat-action' ) ;
33- } catch ( err ) {
34- core . setFailed ( `Failed to run habitat-action: ${ err . message } ` ) ;
35- return ;
36- }
37-
31+ // check if git-holo is already installed
32+ const isInstalled = await exec ( 'which' , [ 'git-holo' ] , { ignoreReturnCode : true , silent : true } ) === 0 ;
3833
39- try {
40- core . startGroup ( 'Installing Jarvus Hologit' ) ;
41- await exec ( 'hab pkg install jarvus/hologit' ) ;
42- } catch ( err ) {
43- core . setFailed ( `Failed to install Jarvus Hologit: ${ err . message } ` ) ;
44- return ;
45- } finally {
46- core . endGroup ( ) ;
34+ if ( isInstalled ) {
35+ core . info ( 'Hologit is already installed, skipping npm install' ) ;
36+ } else {
37+ try {
38+ core . startGroup ( 'Installing Jarvus Hologit' ) ;
39+ await exec ( 'npm install -g hologit' ) ;
40+ } catch ( err ) {
41+ core . setFailed ( `Failed to install Jarvus Hologit: ${ err . message } ` ) ;
42+ return ;
43+ } finally {
44+ core . endGroup ( ) ;
45+ }
4746 }
4847
4948
@@ -151,11 +150,15 @@ async function run() {
151150 core . startGroup ( `Projecting holobranch: ${ holobranch } ` ) ;
152151 const projectionArgs = [
153152 holobranch ,
154- `--ref=${ ref } ` ,
155- '--cache-from=origin' ,
156- '--cache-to=origin'
153+ `--ref=${ ref } `
157154 ] ;
158155
156+ if ( cache ) {
157+ projectionArgs . push ( '--cache-from=origin' , '--cache-to=origin' ) ;
158+ } else {
159+ projectionArgs . push ( '--no-cache-from' , '--no-cache-to' ) ;
160+ }
161+
159162 if ( debug ) {
160163 projectionArgs . push ( '--debug' ) ;
161164 }
@@ -209,17 +212,15 @@ async function run() {
209212}
210213
211214async function gitExec ( command , args = [ ] , options = { } ) {
212- return exec ( 'hab pkg exec jarvus/hologit' , [
213- 'git' ,
215+ return exec ( 'git' , [
214216 '--no-pager' ,
215217 command ,
216218 ...args
217219 ] , options ) ;
218220}
219221
220222async function gitExecOutput ( command , args = [ ] , options = { } ) {
221- return execOutput ( 'hab pkg exec jarvus/hologit' , [
222- 'git' ,
223+ return execOutput ( 'git' , [
223224 '--no-pager' ,
224225 command ,
225226 ...args
0 commit comments