Skip to content

Merge branch 'master' of https://github.com/Saumya40-codes/Doodler #3

Merge branch 'master' of https://github.com/Saumya40-codes/Doodler

Merge branch 'master' of https://github.com/Saumya40-codes/Doodler #3

name: Run Ansible Configurations
on:
push:
branches:
- master
paths:
- 'server/**'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Ansible
run: |
python -m pip install --upgrade pip
pip install ansible
- name: Create Inventory File
run: |
echo "[servers]" > inventory
echo "${{ secrets.EC2_PRIVATE_IP_1 }} ansible_ssh_user=ubuntu" >> inventory
- name: Decrypt secrets file
run: |
echo "${{ secrets.ANSIBLE_VAULT_PASSWORD }}" > .vault_pass
ansible-vault decrypt secrets.yml --vault-password-file .vault_pass
- name: Add SSH key
run: |
mkdir -p ~/.ssh
echo "${{ secrets.EC2_SSH_KEY }}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -H ${{ secrets.EC2_PRIVATE_IP_1 }} >> ~/.ssh/known_hosts
- name: Run Ansible Playbook
run: |
ansible-playbook -i inventory playbook.yml --vault-password-file .vault_pass