@@ -85,6 +85,39 @@ func (opts *GithubAction) execScript(ctx context.Context, path string) error {
85
85
}
86
86
87
87
func (opts * GithubAction ) Run (ctx context.Context , args []string ) (err error ) {
88
+ if opts .RuntimeDir != "" {
89
+ config.G [config.KraftKit ](ctx ).RuntimeDir = opts .RuntimeDir
90
+ }
91
+
92
+ if opts .Auths != "" {
93
+ var auths map [string ]config.AuthConfig
94
+ if err := yaml .Unmarshal ([]byte (opts .Auths ), & auths ); err != nil {
95
+ return fmt .Errorf ("could not parse auths: %w" , err )
96
+ }
97
+
98
+ if config.G [config.KraftKit ](ctx ).Auth == nil {
99
+ config.G [config.KraftKit ](ctx ).Auth = make (map [string ]config.AuthConfig )
100
+ }
101
+
102
+ for domain , auth := range auths {
103
+ config.G [config.KraftKit ](ctx ).Auth [domain ] = auth
104
+ }
105
+ }
106
+
107
+ if opts .Manifests != "" {
108
+ var manifests []string
109
+ if err := yaml .Unmarshal ([]byte (opts .Manifests ), & manifests ); err != nil {
110
+ return fmt .Errorf ("could not parse manifests: %w" , err )
111
+ }
112
+ config.G [config.KraftKit ](ctx ).Unikraft .Manifests = manifests
113
+ }
114
+
115
+ // Save configuration to disk such that uses of `before`, `run` and `after`
116
+ // scripts can access the configuration via `kraft`.
117
+ if err := config.M [config.KraftKit ](ctx ).Write (true ); err != nil {
118
+ return fmt .Errorf ("could not write configuration: %w" , err )
119
+ }
120
+
88
121
if (len (opts .Arch ) > 0 || len (opts .Plat ) > 0 ) && len (opts .Target ) > 0 {
89
122
return fmt .Errorf ("target and platform/architecture are mutually exclusive" )
90
123
}
@@ -113,33 +146,6 @@ func (opts *GithubAction) Run(ctx context.Context, args []string) (err error) {
113
146
log .G (ctx ).SetLevel (logrus .TraceLevel )
114
147
}
115
148
116
- if opts .RuntimeDir != "" {
117
- config.G [config.KraftKit ](ctx ).RuntimeDir = opts .RuntimeDir
118
- }
119
-
120
- if opts .Auths != "" {
121
- var auths map [string ]config.AuthConfig
122
- if err := yaml .Unmarshal ([]byte (opts .Auths ), & auths ); err != nil {
123
- return fmt .Errorf ("could not parse auths: %w" , err )
124
- }
125
-
126
- if config.G [config.KraftKit ](ctx ).Auth == nil {
127
- config.G [config.KraftKit ](ctx ).Auth = make (map [string ]config.AuthConfig )
128
- }
129
-
130
- for domain , auth := range auths {
131
- config.G [config.KraftKit ](ctx ).Auth [domain ] = auth
132
- }
133
- }
134
-
135
- if opts .Manifests != "" {
136
- var manifests []string
137
- if err := yaml .Unmarshal ([]byte (opts .Manifests ), & manifests ); err != nil {
138
- return fmt .Errorf ("could not parse manifests: %w" , err )
139
- }
140
- config.G [config.KraftKit ](ctx ).Unikraft .Manifests = manifests
141
- }
142
-
143
149
if len (opts .Workdir ) == 0 {
144
150
opts .Workdir , err = os .Getwd ()
145
151
if err != nil {
0 commit comments