initial commit #1
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 Workflow | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.9' | |
- name: Install Ansible | |
run: | | |
python -m pip install --upgrade pip | |
pip install ansible | |
- name: Set up SSH | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.DIGITALOCEAN_SSH_PRIVATE_KEY_2 }} | |
# Optional: Test SSH connection to the server | |
- name: Test SSH Connection | |
run: | |
ssh -o StrictHostKeyChecking=no ${{ secrets.DIGITALOCEAN_VM_USERNAME }}@${{ secrets.DIGITALOCEAN_VM_IP }} "echo Connection Successful" | |
- name: Run Ansible Playbook | |
run: | | |
ansible-playbook -i ansible/inventory.ini ansible/install_docker.yml | |
- name: copy file via ssh password | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DIGITALOCEAN_VM_IP }} | |
username: ${{ secrets.DIGITALOCEAN_VM_USERNAME }} | |
key: ${{ secrets.DIGITALOCEAN_SSH_PRIVATE_KEY_2 }} | |
source: "./docker-compose.yml" | |
target: "~/" | |
- name: Deploy using Docker Compose | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DIGITALOCEAN_VM_IP }} | |
username: ${{ secrets.DIGITALOCEAN_VM_USERNAME }} | |
key: ${{ secrets.DIGITALOCEAN_SSH_PRIVATE_KEY_2 }} | |
script: | | |
docker-compose up -d | |