Import Ansible Role #12
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Import Ansible Role | |
| on: # yamllint disable-line rule:truthy | |
| push: | |
| tags: | |
| - '*' | |
| 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 }} | |
| 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.13' | |
| - 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: | | |
| PROJECT_NAME="${ROLE_GIT_REPO##*/}" | |
| echo "repo: $ROLE_GIT_REPO" | |
| echo "owner: $ROLE_GIT_OWNER" | |
| echo "current branch: $BRANCH_NAME" | |
| echo "project name: $PROJECT_NAME" | |
| 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: | | |
| PROJECT_NAME="${ROLE_GIT_REPO##*/}" | |
| ansible-galaxy role import $ANSIBLE_GALAXY_ROLE_DEBUG --branch $BRANCH_NAME $ROLE_GIT_OWNER $PROJECT_NAME |