feat: add workflow for deploying playbook on merge
This commit is contained in:
36
.gitea/workflows/deploy_playbook.yaml
Normal file
36
.gitea/workflows/deploy_playbook.yaml
Normal file
@ -0,0 +1,36 @@
|
||||
name: Ansible CI/CD
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
types: [closed]
|
||||
|
||||
|
||||
jobs:
|
||||
deploy:
|
||||
name: Deploy Ansible Playbook
|
||||
if: github.event.pull_request.merged == true
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up SSH
|
||||
run: |
|
||||
echo "${{ secrets.DEVHOST_SSH_PRIVATE_KEY }}" > private_key.pem
|
||||
chmod 600 private_key.pem
|
||||
|
||||
- name: Install Ansible
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt update
|
||||
sudo apt install -y ansible
|
||||
|
||||
- name: Run Ansible Playbook
|
||||
env:
|
||||
ANSIBLE_USER: ${{ secrets.ANSIBLE_USER }}
|
||||
ANSIBLE_HOST_KEY_CHECKING: False
|
||||
run: |
|
||||
ansible-playbook -i opdracht-2/inventory.ini opdracht-2/nginx.yml --private-key private_key.pem -u ${{ secrets.DEVHOST_ANSIBLE_USER }}
|
Reference in New Issue
Block a user