path finding for relativ requests with custom inv fix #32
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: 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: | | |
pwd | |
echo "LS --------------------" | |
ls -R | |
echo "CONFIG --------------------" | |
cat config.yml | |
echo "PLAYBOOK --------------------" | |
cat test_playbooks/test_playbook.yml | |
- name: Run tests | |
run: | | |
python -m unittest discover src | |
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 }} |