-
-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (130 loc) · 3.73 KB
/
3-main.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
---
name: Main
'on':
push:
branches:
- main
tags-ignore:
- '**'
jobs:
ansible-linter:
name: Ansible Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install ansible-lint Dependencies
run: pip3 install ansible ansible-base ansible-lint
- name: Lint Code Base with ansible-lint
run: ansible-lint
pre-commit:
name: pre-commit
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Run pre-commit
uses: pre-commit/[email protected]
yaml-linter:
name: YAML Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install yamllint Dependencies
run: pip3 install yamllint
- name: Lint Code Base with yamllint
run: yamllint .
molecule:
name: Molecule
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install Molecule Dependencies
run: pip install -r requirements.txt
- name: Run Molecule Tests
run: molecule test --all
env:
PY_COLORS: 1
ANSIBLE_FORCE_COLOR: 1
release:
name: Release
if: ${{ github.event_name != 'schedule' }}
runs-on: ubuntu-latest
needs:
- ansible-linter
- pre-commit
- yaml-linter
- molecule
steps:
- name: Checkout Code
uses: actions/checkout@v2
- name: Create a new tag
uses: phish108/[email protected]
id: autotag
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Create a new release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.autotag.outputs.new-tag }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install ansible-base
run: pip3 install ansible-base
- name: Trigger a new import on Galaxy
run: >-
ansible-galaxy role import
--token "${{ secrets.GALAXY_API_KEY }}"
--branch main
"$(echo ${{ github.repository }} | cut -d/ -f1)"
"$(echo ${{ github.repository }} | cut -d/ -f2)"
playbook:
name: Trigger Playbook Repo
runs-on: ubuntu-latest
needs:
- release
steps:
- name: Trigger racqspace/playbook-longhorn
run: >-
curl -XPOST -u "${{ secrets.PAT_USERNAME}}:${{secrets.PAT}}"
-H "Accept: application/vnd.github.everest-preview+json"
-H "Content-Type: application/json"
https://api.github.com/repos/racqspace/playbook-longhorn/dispatches
--data '{"event_type": "New ansible role version: longhorn"}'
notify:
name: Slack Notifications
runs-on: ubuntu-latest
if: ${{ failure() }}
needs:
- playbook
steps:
- name: Notify Slack channel on failure
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_ICON: https://github.com/ckaserer/logos/raw/master/ansible.png
SLACK_USERNAME: ${{ github.repository }}
SLACK_COLOR: '#ff0033'
SLACK_FOOTER: ''
...