Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions .github/workflows/Deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Ansible Deployment

on:
pull_request:
types: [closed]
branches:
- main
- develop

env:
ANSIBLE_HOST_KEY_CHECKING: "False"

jobs:
deploy-prod:
if: |
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'main'
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Ansible
run: pip install ansible

- name: Load SSH key
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Deploy to PRODUCTION
working-directory: ansible
run: |
echo "${{ secrets.VAULT_PASSWORD_PROD }}" > vault_pass.txt
ansible-playbook -i hosts playbooks/site.yml \
--limit=prod \
--vault-password-file vault_pass.txt \
--diff
rm vault_pass.txt

deploy-preprod:
if: |
github.event.pull_request.merged == true &&
github.event.pull_request.base.ref == 'develop'
runs-on: ubuntu-latest
environment: staging

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install Ansible
run: pip install ansible

- name: Load SSH key
uses: webfactory/ssh-agent@v0.9.0
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Deploy to PRE-PRODUCTION
working-directory: ansible
run: |
echo "${{ secrets.VAULT_PASSWORD_PRE_PROD }}" > vault_pass.txt
ansible-playbook -i hosts playbooks/site.yml \
--limit=pre_prod \
--vault-password-file vault_pass.txt \
--diff
rm vault_pass.txt
Loading
Loading