Skip to content

Deploy to prod server #66

Deploy to prod server

Deploy to prod server #66

Workflow file for this run

name: Deploy to prod server
on:
workflow_run:
workflows: ["Django tests"]
types:
- completed
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
environment: deployment
concurrency:
group: deploy
cancel-in-progress: true
steps:
- name: Checkout Repository
uses: actions/checkout@v2
with:
ref: ${{ github.event.workflow_run.head_branch }}
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Install Ansible
run: |
python -m pip install --upgrade pip
pip install ansible
- name: Install ssh keys
# For reference: https://stackoverflow.com/a/70447517
run: |
install -m 600 -D /dev/null ~/.ssh/galaxy
echo "${{ secrets.SSH_PRIVATE_KEY }}" > ~/.ssh/galaxy
echo "${{ secrets.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts
- name: Add VAULT password
run: |
echo "${{ secrets.ANSIBLE_VAULT_PASS }}" > deploy/ansible/.vault.pass
- name: Install ansible roles
run: |
cd deploy/ansible
ansible-galaxy install -p roles -r requirements.yml
- name: Run Ansible Playbook
run: |
cd deploy/ansible
ansible-playbook -i hosts prod.yml --tags update
env:
ANSIBLE_HOST_KEY_CHECKING: 'False'
ANSIBLE_REMOTE_USER: ${{ secrets.SSH_USER }}