This repository was archived by the owner on May 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
117 lines (113 loc) · 4.23 KB
/
Copy pathtest.yml
File metadata and controls
117 lines (113 loc) · 4.23 KB
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
name: Test
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
branches: [master]
env:
ROLE_NAME: getstackhead.stackhead_webserver_caddy
WEBSERVER: getstackhead.stackhead_webserver_caddy
DOMAIN_NAME: "pr-${{ github.run_id }}-caddy"
DOMAIN_SUFFIX: "test.stackhead.io"
jobs:
smoke:
name: Smoketest test-tf-generation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Ansible v2.10 alpha (GH actions currently uses 2.9)
run: ANSIBLE_SKIP_CONFLICT_CHECK=1 pip install --user ansible==2.10.0a9 && ansible --version
- name: Get latest StackHead version
run: ansible-galaxy collection install git+https://github.com/getstackhead/stackhead.git,next -f
- run: pip install -r ./requirements/pip.txt
- run: ansible-playbook ./__tests__/test-tf-generation.yml
checkLabel:
name: Please request integration test and review
needs: smoke
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
steps:
- run: if [ ${{ contains( github.event.pull_request.labels.*.name, 'action/integration-test') }} == false ]; then exit 1; else exit 0; fi
test:
name: Integration Test
needs: checkLabel
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
env:
INVENTORY_PATH: __tests__/inventory.yml
steps:
- uses: actions/checkout@v2
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Uninstall old Ansible
run: ansible --version && sudo apt purge ansible -y
- name: Install Ansible v2.10 alpha (GH actions currently uses 2.9)
run: sudo python -m pip install ansible==2.10.0a9 && ansible --version
- run: pip install -r ./requirements/pip.txt
- name: Print Ansible version
run: ansible --version
- uses: webfactory/ssh-agent@v0.2.0
with:
ssh-private-key: "${{ secrets.SSH_PRIVATE_KEY }}"
- name: Setup Hetzner server
id: setup_server
uses: saitho/hetzner-cloud-action@v1.1.0
with:
action: create
server_name: "${{ env.DOMAIN_NAME }}"
server_image: ubuntu-18.04
server_location: fsn1
server_ssh_key_name: gh-actions
wait_for_ssh: 1
env:
API_TOKEN: ${{ secrets.HETZNER_TOKEN }}
- name: Add DNS record
uses: saitho/create-dns-record@patch-1
with:
type: "A"
name: "${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
content: "${{ steps.setup_server.outputs.hcloud_server_created_ipv4 }}"
ttl: 1
proxied: 0
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
- name: Add DNS record for subdomain
uses: saitho/create-dns-record@patch-1
with:
type: "A"
name: "sub.${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
content: "${{ steps.setup_server.outputs.hcloud_server_created_ipv4 }}"
ttl: 1
proxied: 0
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
- uses: getstackhead/stackhead/actions/integration-test@next
with:
ipaddress: ${{ steps.setup_server.outputs.hcloud_server_created_ipv4 }}
domain: '${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}'
domain2: 'sub.${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}'
webserver: '${{ env.WEBSERVER }}'
rolename: '${{ env.ROLE_NAME }}'
- name: Remove DNS record
uses: saitho/delete-dns-record@saitho-patch-1
if: always()
with:
name: "${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
- name: Remove DNS record for subdomain
uses: saitho/delete-dns-record@saitho-patch-1
if: always()
with:
name: "sub.${{ env.DOMAIN_NAME }}.${{ env.DOMAIN_SUFFIX }}"
token: "${{ secrets.CLOUDFLARE_TOKEN }}"
zone: "${{ secrets.CLOUDFLARE_ZONE }}"
- name: Remove Hetzner server
uses: saitho/hetzner-cloud-action@v1.1.0
if: always()
with:
action: remove
server_id: "${{ steps.setup_server.outputs.hcloud_server_id }}"
env:
API_TOKEN: ${{ secrets.HETZNER_TOKEN }}