-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (55 loc) · 1.81 KB
/
gitops.yaml
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
61
62
63
64
65
---
name: GitOps
on:
push:
branches: [main]
pull_request:
# schedule:
# - cron: '53 1 */15 * *'
jobs:
# lint:
# runs-on: ubuntu-latest
# container:
# image: ghcr.io/secshellnet/ansible-creator-ee # ghcr.io/ansible/creator-ee with preinstalled collections
#
# steps:
# - uses: actions/checkout@v3
#
# - name: Run ansible-lint
# run: |
# ansible-lint -x command-instead-of-shell,no-changed-when,\
# name[template],jinja[invalid]
run:
runs-on: ubuntu-latest
# needs: [lint]
steps:
- uses: actions/checkout@v3
if: vars.ENABLE_GITOPS == '1'
- name: Prepare environment
if: vars.ENABLE_GITOPS == '1'
run: |
echo "${{ secrets.SSH_KEY }}" > .keys/id_ecdsa
chmod 600 .keys/id_ecdsa
ssh-keygen -f .keys/id_ecdsa -y > .keys/id_ecdsa.pub
echo "${{ secrets.ANSIBLE_KEYS_ALL }}" > .keys/all
ansible-galaxy collection install hetzner.hcloud community.general ansible.posix
ansible-galaxy role install geerlingguy.postgresql geerlingguy.redis
/opt/pipx/venvs/ansible-core/bin/python -m pip install -r requirements.txt
# not quiet sure why, but we need this package in this python environment
pip3 install python-dateutil
- name: Run ansible inventory in check mode
if: |
vars.ENABLE_GITOPS == '1' &&
github.event_name == 'pull_request'
env:
ANSIBLE_HOST_KEY_CHECKING: false
run: |
ansible-playbook playbook.yaml --check
- name: Deploy ansible inventory
if: |
vars.ENABLE_GITOPS == '1'
&& github.event_name != 'pull_request'
env:
ANSIBLE_HOST_KEY_CHECKING: false
run: |
ansible-playbook playbook.yaml