-
Notifications
You must be signed in to change notification settings - Fork 0
60 lines (55 loc) · 1.61 KB
/
deploy-front.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
name: Deploy Front with Ansible
on:
pull_request:
paths:
- 'front/**'
branches:
- main
types: [closed]
jobs:
deploy:
name: Deploy Ansible Playbook
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
defaults:
run:
working-directory: ./front
environment: production
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up SSH
run: |
echo "${{ secrets.SSH_PRIVATE_KEY }}" > private_key.pem
chmod 600 private_key.pem
- name: Create and populate inventory file
working-directory: ./deploy
env:
ANSIBLE_INVENTORY: ${{ secrets.ANSIBLE_INVENTORY }}
run: |
touch inventory.ini
echo $ANSIBLE_INVENTORY >> inventory.ini
- name: Create and populate vault.yml vars file
working-directory: ./deploy
env:
ANSIBLE_VAULT: ${{ secrets.ANSIBLE_VAULT }}
run: |
touch vars/vault.yml
echo $ANSIBLE_VAULT >> vars/vault.yml
- name: Setup
uses: actions/setup-node@v4
with:
node-version: '20.x'
- run: npm run build:prod
- name: Install Ansible
shell: bash
run: |
sudo apt update
sudo apt install -y ansible
- name: Run Ansible Playbook
working-directory: ./deploy
env:
BECOME_PASSWORD_FILE: ${{ secrets.ANSIBLE_BECOME_PASSWORD }}
ANSIBLE_HOST_KEY_CHECKING: False
run: |
ansible-playbook front.yml -i inventory.ini --private-key private_key.pem