-
Notifications
You must be signed in to change notification settings - Fork 6
58 lines (49 loc) · 1.5 KB
/
deploy-dev.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
name: Deploy to dev server
on:
workflow_run:
workflows: ["Django tests"]
types:
- completed
branches:
- dev
jobs:
deploy:
runs-on: ubuntu-latest
environment: deployment
concurrency:
group: deploy-dev
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_DEV }}" > ~/.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 dev.yml --tags update
env:
ANSIBLE_HOST_KEY_CHECKING: 'False'
ANSIBLE_REMOTE_USER: ${{ secrets.SSH_USER }}
ANSIBLE_PRIVATE_KEY_FILE: ~/.ssh/galaxy