88	"flag" 
99	"fmt" 
1010	"io/ioutil" 
11- 	"log" 
1211	"os" 
1312	"os/exec" 
1413	"path/filepath" 
@@ -29,11 +28,10 @@ type Action struct {
2928}
3029
3130type  ActionStep  struct  {
32- 	Type        string    `json:"type"`  // "command" 
33- 	Dockerfile  string    `json:"dockerfile,omitempty"` 
34- 	Image       string    `json:"image,omitempty"`  // Docker image 
35- 	CacheDirs   []string  `json:"cacheDirs,omitempty"` 
36- 	Args        []string  `json:"args,omitempty"` 
31+ 	Type       string    `json:"type"`             // "command" 
32+ 	Image      string    `json:"image,omitempty"`  // Docker image 
33+ 	CacheDirs  []string  `json:"cacheDirs,omitempty"` 
34+ 	Args       []string  `json:"args,omitempty"` 
3735
3836	// ImageContentDigest is an internal field that should not be set by users. 
3937	ImageContentDigest  string 
@@ -61,21 +59,21 @@ Execute an action on code in repositories. The output of an action is a set of p
6159
6260Examples: 
6361
64-   Execute an action defined in ~/run-gofmt-in-dockerfile .json: 
62+   Execute an action defined in ~/run-gofmt.json: 
6563
66- 	$ src actions exec -f ~/run-gofmt-in-dockerfile .json 
64+ 	$ src actions exec -f ~/run-gofmt.json 
6765
6866  Execute an action and create a campaign plan from the patches it produced: 
6967
70- 	$ src actions exec -f ~/run-gofmt-in-dockerfile .json -create-plan 
68+ 	$ src actions exec -f ~/run-gofmt.json -create-plan 
7169
7270  Verbosely execute an action and keep the logs available for debugging: 
7371
74- 	$ src -v actions exec -keep-logs -f ~/run-gofmt-in-dockerfile .json 
72+ 	$ src -v actions exec -keep-logs -f ~/run-gofmt.json 
7573
7674  Execute an action and pipe the patches it produced to 'src campaign plan create-from-patches': 
7775
78- 	$ src actions exec -f ~/run-gofmt-in-dockerfile .json | src campaign plan create-from-patches 
76+ 	$ src actions exec -f ~/run-gofmt.json | src campaign plan create-from-patches 
7977
8078  Read and execute an action definition from standard input: 
8179
@@ -105,13 +103,13 @@ Format of the action JSON files:
105103
106104	This action runs a single step over repositories whose name contains "github", building and starting a Docker container based on the image defined through the "dockerfile". In the container the word 'this' is replaced with 'that' in all text files. 
107105
108- 
109106		{ 
110107		  "scopeQuery": "repo:github", 
111108		  "steps": [ 
112109		    { 
113110		      "type": "docker", 
114- 		      "dockerfile": "FROM alpine:3 \n CMD find /work -iname '*.txt' -type f | xargs -n 1 sed -i s/this/that/g" 
111+ 		      "image": "alpine:3", 
112+ 			  "args": ["sh", "-c", "find /work -iname '*.txt' -type f | xargs -n 1 sed -i s/this/that/g"] 
115113		    } 
116114		  ] 
117115		} 
@@ -291,12 +289,8 @@ Format of the action JSON files:
291289func  validateAction (ctx  context.Context , action  Action ) error  {
292290	for  _ , step  :=  range  action .Steps  {
293291		if  step .Type  ==  "docker"  {
294- 			if  step .Dockerfile  ==  ""  &&  step .Image  ==  ""  {
295- 				return  fmt .Errorf ("docker run step has to specify either 'image' or 'dockerfile'" )
296- 			}
297- 
298- 			if  step .Dockerfile  !=  ""  &&  step .Image  !=  ""  {
299- 				return  fmt .Errorf ("docker run step may specify either image (%q) or dockerfile, not both" , step .Image )
292+ 			if  step .Image  ==  ""  {
293+ 				return  fmt .Errorf ("docker run step has to specify 'image'" )
300294			}
301295
302296			if  step .ImageContentDigest  !=  ""  {
@@ -314,44 +308,8 @@ func validateAction(ctx context.Context, action Action) error {
314308
315309func  prepareAction (ctx  context.Context , action  Action ) error  {
316310	// Build any Docker images. 
317- 	for  i , step  :=  range  action .Steps  {
311+ 	for  _ , step  :=  range  action .Steps  {
318312		if  step .Type  ==  "docker"  {
319- 			if  step .Dockerfile  ==  ""  &&  step .Image  ==  ""  {
320- 				return  fmt .Errorf ("docker run step has to specify either 'image' or 'dockerfile'" )
321- 			}
322- 
323- 			if  step .Dockerfile  !=  ""  &&  step .Image  !=  ""  {
324- 				return  fmt .Errorf ("docker run step may specify either image (%q) or dockerfile, not both" , step .Image )
325- 			}
326- 
327- 			if  step .Dockerfile  !=  ""  {
328- 				iidFile , err  :=  ioutil .TempFile ("" , "src-actions-exec-image-id" )
329- 				if  err  !=  nil  {
330- 					return  err 
331- 				}
332- 				defer  os .Remove (iidFile .Name ())
333- 
334- 				if  * verbose  {
335- 					log .Printf ("Building Docker container for step %d..." , i )
336- 				}
337- 
338- 				cmd  :=  exec .CommandContext (ctx , "docker" , "build" , "--iidfile" , iidFile .Name (), "-" )
339- 				cmd .Stdin  =  strings .NewReader (step .Dockerfile )
340- 				verboseCmdOutput (cmd )
341- 				if  err  :=  cmd .Run (); err  !=  nil  {
342- 					return  errors .Wrap (err , "build docker image" )
343- 				}
344- 				if  * verbose  {
345- 					log .Printf ("Done building Docker container for step %d." , i )
346- 				}
347- 
348- 				iid , err  :=  ioutil .ReadFile (iidFile .Name ())
349- 				if  err  !=  nil  {
350- 					return  err 
351- 				}
352- 				step .Image  =  string (iid )
353- 			}
354- 
355313			// Set digests for Docker images so we don't cache action runs in 2 different images with 
356314			// the same tag. 
357315			if  step .Image  !=  ""  {
0 commit comments