fix workflow #11
This file contains hidden or 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 Deployment | |
| on: | |
| push: | |
| #branches: [ main, master ] | |
| paths: | |
| - 'ansible/**' | |
| - '!ansible/docs/**' | |
| - '.github/workflows/ansible-deploy.yml' | |
| pull_request: | |
| #branches: [ main, master ] | |
| paths: | |
| - 'ansible/**' | |
| jobs: | |
| lint: | |
| name: Ansible Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.12' | |
| - name: Install dependencies | |
| run: | | |
| pip install ansible ansible-lint | |
| - name: Run ansible-lint | |
| run: | | |
| cd ansible | |
| ansible-lint playbooks/*.yml | |
| deploy: | |
| name: Deploy Application | |
| needs: lint | |
| runs-on: self-hosted | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Ansible | |
| run: | | |
| sudo apt update | |
| sudo apt install -y ansible | |
| - name: Deploy with Ansible | |
| run: | | |
| cd ansible | |
| ansible-playbook playbooks/deploy.yml \ | |
| --tags "app_deploy" \ | |
| --connection=local \ | |
| --inventory="localhost," \ | |
| -e "ansible_host=127.0.0.1" | |
| - name: Verify Deployment | |
| run: | | |
| sleep 10 # Wait for app to start | |
| curl -f http://localhost:8000 || exit 1 | |
| curl -f http://localhost:8000/health || exit 1 |