Initial commit #2
This file contains 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
--- | |
# This workflow requires a GALAXY_API_KEY secret present in the GitHub | |
# repository or organization. | |
name: Import to Galaxy | |
'on': | |
push: | |
branches: | |
- main | |
paths: | |
- "galaxy.yml" | |
workflow_dispatch: | |
permissions: | |
contents: write | |
jobs: | |
galaxy-import: | |
name: Import to Galaxy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out the codebase. | |
uses: actions/checkout@v3 | |
- name: Get version from "galaxy.yml". | |
id: version | |
run: echo "collection_version=$(yq '.version' galaxy.yml)" >> "$GITHUB_ENV" | |
- name: Check if tag already exists | |
uses: mukunku/[email protected] | |
id: check-tag | |
with: | |
tag: '${{ env.collection_version }}' | |
- name: Set up Python 3. | |
if: "${{ steps.check-tag.outputs.exists == 'false' }}" | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install Ansible. | |
if: "${{ steps.check-tag.outputs.exists == 'false' }}" | |
run: pip3 install ansible-core | |
- name: Trigger a new import on Galaxy. | |
if: "${{ steps.check-tag.outputs.exists == 'false' }}" | |
run: >- | |
ansible-galaxy collection build && | |
ansible-galaxy collection publish --api-key ${{ secrets.GALAXY_API_KEY }} $(ls -t *.tar.gz | head -n 1) | |
- name: Add tag. | |
if: "${{ steps.check-tag.outputs.exists == 'false' }}" | |
uses: anothrNick/[email protected] # Don't use @master unless you're happy to test the latest version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
CUSTOM_TAG: ${{ env.collection_version }} | |
... |