Skip to content

Import Ansible Role

Import Ansible Role #7

name: Import Ansible Role
on: # yamllint disable-line rule:truthy
push:
tags:
- '*'
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.13'
- name: Install ansible-core
run: |
python -m pip install --upgrade pip
pip install ansible-core
- name: Show info about the role
env:
ANSIBLE_GALAXY_API_KEY: ${{ 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 }}}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
PROJECT_NAME="${ROLE_GIT_REPO##*/}"
echo "repo: $ROLE_GIT_REPO"
echo "current branch: $BRANCH_NAME"
echo "project name: $PROJECT_NAME"
ansible-galaxy $ANSIBLE_GALAXY_ROLE_DEBUG role info $ANSIBLE_GALAXY_ROLE_NAME
- name: Import role to Ansible Galaxy
if: ${{ github.ref_name == env.VERSION_FILE_CONTENT }}
env:
ANSIBLE_GALAXY_API_KEY: ${{ secrets.ANSIBLE_GALAXY_API_KEY }}
ANSIBLE_GALAXY_ROLE_DEBUG: ${{ vars.ANSIBLE_GALAXY_ROLE_DEBUG }}
ROLE_GIT_REPO: ${{ github.repository }}}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
run: |
PROJECT_NAME="${ROLE_GIT_REPO##*/}"
ansible-galaxy $ANSIBLE_GALAXY_ROLE_DEBUG role import --branch $BRANCH_NAME rmenage $PROJECT_NAME