Skip to content

Commit

Permalink
Allow to pass config path.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed Jan 21, 2024
1 parent 4d1ca61 commit 49327a2
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
13 changes: 9 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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

Expand Down
37 changes: 33 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 49327a2

Please sign in to comment.