@@ -224,9 +224,21 @@ runs:
224
224
with OUTPUTS_FILE_PATH.open(FILE_APPEND_MODE) as outputs_file:
225
225
outputs_file.writelines(f'{name}={value}{os.linesep}')
226
226
227
+ directory = "${{
228
+ format(
229
+ '{0}/{1}',
230
+ (
231
+ inputs.collection-src-directory
232
+ && inputs.collection-src-directory
233
+ || '.tmp-ansible-collection-checkout'
234
+ ),
235
+ inputs.collection-root
236
+ )
237
+ }}"
238
+
227
239
COLLECTION_META_FILE = 'galaxy.yml'
228
- with open(COLLECTION_META_FILE) as galaxy_yml:
229
- collection_meta = yaml.load (galaxy_yml)
240
+ with open(os.path.join(directory, COLLECTION_META_FILE) ) as galaxy_yml:
241
+ collection_meta = yaml.safe_load (galaxy_yml)
230
242
231
243
coll_name = collection_meta['name']
232
244
coll_ns = collection_meta['namespace']
@@ -235,29 +247,35 @@ runs:
235
247
set_output('namespace', coll_ns)
236
248
237
249
set_output('fqcn', f'{coll_ns}.{coll_name}')
238
- set_output('collection-namespace-path', f'ansible_collections/{coll_ns}')
239
- set_output('checkout-path', f'ansible_collections/{coll_ns}/{coll_name}')
250
+
251
+ wanted_path = f'ansible_collections{os.sep}{coll_ns}{os.sep}{coll_name}'
252
+ if directory.endswith(wanted_path):
253
+ set_output('copy-to-checkout-path', 'false')
254
+ set_output(
255
+ 'collection-namespace-path',
256
+ os.path.normpath(os.path.join(directory, '..')))
257
+ set_output('checkout-path', directory)
258
+ else:
259
+ set_output('copy-to-checkout-path', 'true')
260
+ set_output(
261
+ 'collection-namespace-path',
262
+ os.path.join('ansible_collections', coll_ns))
263
+ set_output(
264
+ 'checkout-path',
265
+ os.path.join('ansible_collections', coll_ns, coll_name))
240
266
shell : python
241
- working-directory : >-
242
- ${{
243
- format(
244
- '{0}/{1}',
245
- (
246
- inputs.collection-src-directory
247
- && inputs.collection-src-directory
248
- || '.tmp-ansible-collection-checkout'
249
- ),
250
- inputs.collection-root
251
- )
252
- }}
253
267
254
268
- name : Log the next step action
269
+ if : >-
270
+ ${{ fromJSON(steps.collection-metadata.outputs.copy-to-checkout-path) }}
255
271
run : >-
256
272
echo ▷ ${{ inputs.collection-src-directory && 'Copy' || 'Move' }}
257
273
"'${{ steps.collection-metadata.outputs.fqcn }}'"
258
274
collection to ${{ steps.collection-metadata.outputs.checkout-path }}...
259
275
shell : bash
260
276
- name : Move the collection to the proper path
277
+ if : >-
278
+ ${{ fromJSON(steps.collection-metadata.outputs.copy-to-checkout-path) }}
261
279
run : >-
262
280
set -x
263
281
;
0 commit comments