Fabian Koller 8f1e95a0ce
Fix GitHub actions
Follow-up to #630.
The check for the target git sha can does not work in the molecule step.
Instead expose the sha through an env variable in GitHub actions.
2021-02-26 19:39:44 +01:00

79 lines
2.8 KiB
YAML

---
name: Ansible Role
on:
push:
branches-ignore:
- 'translations**'
pull_request:
branches-ignore:
- 'translations**'
jobs:
# https://molecule.readthedocs.io/en/latest/ci.html#github-actions
test:
runs-on: ubuntu-latest
steps:
- name: Check out the codebase
uses: actions/checkout@v2
if: github.event_name != 'pull_request'
with:
path: "${{ github.repository }}"
- name: Check out the codebase
uses: actions/checkout@v2
if: github.event_name == 'pull_request'
with:
# merge commit is not available from tree at this point in time
# https://github.com/actions/checkout#checkout-pull-request-head-commit-instead-of-merge-commit
ref: "${{ github.event.pull_request.head.sha }}"
path: "${{ github.repository }}"
- name: Set up Python
uses: actions/setup-python@v2
- name: Set up Docker
uses: docker-practice/actions-setup-docker@master
- name: Install dependencies
run: |
python3 -m pip install --upgrade pip
python3 -m pip install molecule[ansible,docker] jmespath
ansible --version
docker --version
molecule --version
python --version
- name: Test installation/build/upgrade with molecule
run: |
cd ansible
molecule create
molecule verify
molecule converge
molecule idempotence
molecule verify
working-directory: "${{ github.repository }}"
env:
TARGET_GITHUB_SHA: "${{ github.event.pull_request.head.sha }}"
# # https://galaxy.ansible.com/docs/contributing/importing.html
# release:
# runs-on: ubuntu-latest
# needs:
# - test
# # https://docs.github.com/en/free-pro-team@latest/actions/reference/context-and-expression-syntax-for-github-actions#github-context
# if: contains(github.ref, 'refs/tags/')
# steps:
# - name: Check out the codebase
# uses: actions/checkout@v2
# with:
# path: "${{ github.repository }}"
# - name: Set up Python
# uses: actions/setup-python@v2
# - name: Install dependencies
# run: |
# python3 -m pip install --upgrade ansible-base
# ansible --version
# python --version
# - name: Trigger a new import on Galaxy
# # TODO Check if source if pulled from cwd or imported from github
# # https://github.com/ansible/ansible/blob/devel/lib/ansible/cli/galaxy.py
# run: |
# cd ansible
# ansible-galaxy role import --api-key ${{ secrets.GALAXY_API_KEY }} $(echo ${{ github.repository }} | cut -d/ -f1) $(echo ${{ github.repository }} | cut -d/ -f2)
# working-directory: "${{ github.repository }}"