CI #1367
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
--- | |
name: CI | |
'on': | |
pull_request: | |
push: | |
branches: | |
- main | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
lint: | |
name: Lint | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Check out the codebase. | |
uses: actions/checkout@main | |
- name: Set up Python 3. | |
uses: actions/setup-python@main | |
with: | |
python-version: '3.10' | |
- name: Install test dependencies. | |
run: pip3 install yamllint ansible-lint ansible --pre | |
- name: Lint code. | |
run: | | |
yamllint . | |
ansible-lint roles | |
molecule: | |
name: Molecule | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
https: [false, true] | |
cloudflare: [false, true] | |
staging: [false, true] | |
mysql_initial: [false, true] | |
distro: [debian11] | |
steps: | |
- name: Check out the codebase. | |
uses: actions/checkout@main | |
- name: Set up Python 3. | |
uses: actions/setup-python@main | |
with: | |
python-version: '3.x' | |
- name: Install test dependencies. | |
run: pip3 install ansible molecule-plugins[docker] docker 'requests<2.32.0' | |
- name: Fix apparmor mess in ubuntu host! | |
run: | | |
set -x | |
sudo apt-get remove mysql-server --purge | |
sudo apt-get update | |
# sudo apt-get dist-upgrade -y | |
sudo apt-get install apparmor-profiles -y | |
sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld | |
- name: Run Molecule tests. | |
run: molecule test | |
env: | |
PY_COLORS: '1' | |
ANSIBLE_FORCE_COLOR: '1' | |
MOLECULE_DISTRO: ${{ matrix.distro }} | |
HTTPS: ${{ matrix.https }} | |
CLOUDFLARE: ${{ matrix.cloudflare }} | |
STAGING: ${{ matrix.staging }} | |
MYSQL_INITIAL: ${{ matrix.mysql_initial }} | |
deploy: | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
needs: [lint, molecule] | |
name: Push to Galaxy | |
runs-on: ubuntu-20.04 | |
steps: | |
- name: Check out the codebase. | |
uses: actions/checkout@main | |
- name: Set up Python 3. | |
uses: actions/setup-python@main | |
with: | |
python-version: '3.x' | |
- name: Install ansible-core. | |
run: pip3 install ansible-core --pre | |
- name: Push to galaxy if version has been bumped. | |
run: | | |
ansible-galaxy collection download --download-path /tmp aminvakil.lamp | |
if [ "$(grep version: /tmp/requirements.yml | tr -d '[:space:]')" != "$(grep version: galaxy.yml | tr -d '[:space:]')" ]; then | |
ansible-galaxy collection build | |
ansible-galaxy collection publish aminvakil-lamp-*.tar.gz --token ${{ secrets.GALAXY_API_KEY }} | |
fi |