Skip to content

fix: factory update #174

fix: factory update

fix: factory update #174

name: AiXp Factory CI
on:
push:
paths:
- 'aixp_factory/**' # Specify path to your collection
jobs:
build-and-push-collection:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Ansible
run: pip install ansible
- name: Retrieve version from galaxy.yml
id: repo_version
run: |
repo_version=$(grep 'version:' aixp_factory/galaxy.yml | cut -d ' ' -f 2)
echo "current_version=$repo_version" >> $GITHUB_OUTPUT
echo "Current version is $repo_version"
- name: Install collection from Ansible Galaxy
run: ansible-galaxy collection install aidamian.aixp_factory
- name: Get installed collection version
id: ansible_galaxy_version
run: |
collection_version=$(ansible-galaxy collection list | grep 'aidamian.aixp_factory' | awk '{print $2}')
echo "online_version=$collection_version" >> $GITHUB_OUTPUT
echo "Online version is $collection_version"
- name: Compare versions and build if necessary
run: |
cd aixp_factory
current_folder=$(pwd)
echo "Working in $current_folder"
current_version=${{ steps.repo_version.outputs.current_version }}
galaxy_version=${{ steps.ansible_galaxy_version.outputs.online_version }}
if [ "$current_version" != "$galaxy_version" ]; then
echo "Building and pushing version $current_version, which is newer than the version $galaxy_version on Ansible Galaxy."
ansible-galaxy collection build
ansible-galaxy collection publish ./*.tar.gz --api-key ${{ secrets.ANSIBLE_GALAXY_API_TOKEN }}
else
echo "The collection version $current_version has not changed compared to the version $galaxy_version on Ansible Galaxy. No action is required."
fi