diff --git a/README.md b/README.md index c70a8d8..1562c4a 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,12 @@ To use the action, add the following step to your workflow file (for example `.g The follow options can be provided to this GitHub Action. +### `artifact-path` + +Path to the collection's build artifact (tarball). + +**(REQUIRED)** + ### `python-version` The Python version to use. @@ -49,11 +55,10 @@ This is assumed to exist in https://github.com/ansible/ansible. Path to a Galaxy requirements file. If present, these collections will be installed. -### `artifact-path` +### `importer-config-path` -Path to the collection's build artifact (tarball). - -**(REQUIRED)** +Path to a Galaxy importer configuration file. +See https://github.com/ansible/galaxy-importer#configuration for more information. ## Bundled shared workflow diff --git a/action.yml b/action.yml index 8f0975a..dc87efa 100644 --- a/action.yml +++ b/action.yml @@ -8,6 +8,10 @@ description: >- This action tries to import a built Ansible collection artifact with the Ansible Galaxy importer. author: "Felix Fontein (@felixfontein)" inputs: + artifact-path: + description: >- + Path to the collection's build artifact (tarball). + required: true python-version: description: |- The Python version to use. @@ -22,10 +26,10 @@ inputs: collection-requirements-path: description: >- Path to a Galaxy requirements file. If present, these collections will be installed. - artifact-path: + importer-config-path: description: >- - Path to the collection's build artifact (tarball). - required: true + Path to a Galaxy importer configuration file. + See https://github.com/ansible/galaxy-importer#configuration for more information. runs: using: composite steps: @@ -53,12 +57,37 @@ runs: run: | ansible-galaxy collection install --pre --requirements-file "${COLLECTION_REQUIREMENTS_PATH}" + - name: Preparations + id: preparations + env: + ARTIFACT_PATH: ${{ inputs.artifact-path }} + IMPORTER_CONFIG_PATH: ${{ inputs.importer-config-path }} + shell: python + run: | + # Preparations + + import os + import shlex + + def set_output(name, value): + with open(os.environ['GITHUB_OUTPUT'], 'a', encoding='utf-8') as f: + f.write(f'{name}={value}{os.linesep}') + + artifact_path = os.environ['ARTIFACT_PATH'] + importer_config_path = os.environ['IMPORTER_CONFIG_PATH'] + + command = ['python', '-m', 'galaxy_importer.main', artifact_path] + if importer_config_path: + command.insert(0, f'GALAXY_IMPORTER_CONFIG={importer_config_path}') + + set_output('command', shlex.join(command)) + - name: Run Galaxy importer shell: bash env: ARTIFACT_PATH: ${{ inputs.artifact-path }} run: | - python -m galaxy_importer.main "${ARTIFACT_PATH}" | tee import.log + ${{ steps.preparations.outputs.command }} | tee import.log - name: Analyze result shell: python