Skip to content

init_app and main splittet for better import #28

init_app and main splittet for better import

init_app and main splittet for better import #28

Workflow file for this run

name: Ansible-Link CI/CD
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
ansible-link-ci:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Update configuration
working-directory: ${{ github.workspace }}/src
run: |
sed -i '/^playbook_dir:/d' config.yml
sed -i '/^inventory_file:/d' config.yml
sed -i '/^job_storage_dir:/d' config.yml
sed -i '/^log_level:/d' config.yml
sed -i '/^playbook_whitelist:/d' config.yml
echo "playbook_dir: './test_playbooks'" >> config.yml
echo "inventory_file: './test_inventory.ini'" >> config.yml
echo "job_storage_dir: './test_job_storage'" >> config.yml
echo "log_level: 'DEBUG'" >> config.yml
echo "playbook_whitelist:" >> config.yml
echo " - test_.+\.yml$" >> config.yml
- name: create test files/folders
working-directory: ${{ github.workspace }}/src
run: |
mkdir -p test_playbooks test_job_storage
touch test_inventory.ini
- name: create test playbook
working-directory: ${{ github.workspace }}/src
run: |
cat << EOF > test_playbooks/test_playbook.yml
---
- name: Test Playbook
hosts: localhost
connection: local
tasks:
- name: Print a message
debug:
msg: "This is a test playbook"
EOF
- name: show structure and files
working-directory: ${{ github.workspace }}/src
run: |
ls -R
cat config.yml
cat test_playbooks/test_playbook.yml
- name: run tests
run: |
python -m unittest discover tests
build-and-release:
needs: ansible-link-ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.8'
- name: Get version
id: get_version
run: |
echo "VERSION=$(python -c "from src.version import VERSION; print(VERSION)")" >> $GITHUB_OUTPUT
- name: Create zip artifact
run: |
zip -r ansible-link-${{ steps.get_version.outputs.VERSION }}.zip src -x "*.pyc" "*__pycache__*" "test_*"
- name: Create hash file
run: |
sha256sum ansible-link-${{ steps.get_version.outputs.VERSION }}.zip > ansible-link-${{ steps.get_version.outputs.VERSION }}.sha256
- name: Release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
ansible-link-${{ steps.get_version.outputs.VERSION }}.zip
ansible-link-${{ steps.get_version.outputs.VERSION }}.sha256
name: Release ${{ steps.get_version.outputs.VERSION }}
body_path: ${{ github.workspace }}/CHANGELOG.md
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}