Skip to content

Import Ansible Role #20

Import Ansible Role

Import Ansible Role #20

name: Import Ansible Role
on: # yamllint disable-line rule:truthy
push:
tags:
- '*'
env:
ANSIBLE_GALAXY_SERVER_GALAXY_TOKEN: ${{ secrets.ANSIBLE_GALAXY_API_KEY }}
ANSIBLE_GALAXY_ROLE_DEBUG: ${{ vars.ANSIBLE_GALAXY_ROLE_DEBUG }}
ANSIBLE_GALAXY_ROLE_NAME: ${{ vars.ANSIBLE_GALAXY_ROLE_NAME }}
ROLE_GIT_REPO: ${{ github.repository }}
ROLE_GIT_OWNER: ${{ github.repository_owner }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
import-role:
runs-on: ubuntu-latest
environment: live
steps:
- name: Checkout default branch to read VERSION
uses: actions/checkout@v6
with:
ref: ${{ github.event.repository.default_branch }}
- name: Capture VERSION content
id: read_version
run: echo "VERSION_FILE_CONTENT=$(cat VERSION)" >> "$GITHUB_ENV"
- name: Checkout tag source
uses: actions/checkout@v6 # default ref is the tag that triggered
- name: Set up Python 3.13
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install ansible-core
run: |
python -m pip install --upgrade pip
pip install ansible-core
- name: Show info about the role on Ansible galaxy before new import
run: |
ansible-galaxy "$ANSIBLE_GALAXY_ROLE_DEBUG" role info "$ANSIBLE_GALAXY_ROLE_DEBUG" "$ANSIBLE_GALAXY_ROLE_NAME"
- name: Import role to Ansible Galaxy
#if: ${{ github.ref_name == env.VERSION_FILE_CONTENT }}
run: |
ansible-galaxy role import "$ANSIBLE_GALAXY_ROLE_DEBUG" --branch "$BRANCH_NAME" --server https://galaxy.ansible.com/api/ --token "$ANSIBLE_GALAXY_SERVER_GALAXY_TOKEN" "$ROLE_GIT_OWNER" "${ROLE_GIT_REPO##*/}"