This repository was archived by the owner on Sep 7, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (94 loc) · 3.54 KB
/
Copy pathtest.yml
File metadata and controls
101 lines (94 loc) · 3.54 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
name: Test
# This workflow will setup an integration test environment
# - launch webserver at Hetzner Cloud
# - setup domain DNS at Cloudflare for two domains
# - [DOMAIN_NAME].[DOMAIN_SUFFIX]
# - sub.[DOMAIN_NAME].[DOMAIN_SUFFIX]
#
# This test workflow requires the following environment variables:
# - SSH_PRIVATE_KEY
# - CLOUDFLARE_TOKEN
# - CLOUDFLARE_ZONE
# - HETZNER_TOKEN
# Also create a label "action/integration-test"
# Only pull requests with that label will be integration tested
on:
pull_request:
types: [opened, labeled, unlabeled, synchronize]
branches: [master]
env:
ROLE_NAME: getstackhead.stackhead_dns_cloudflare
DNS: getstackhead.stackhead_dns_cloudflare
WEBSERVER: getstackhead.stackhead_webserver_nginx
CONTAINER: getstackhead.stackhead_container_docker
DOMAIN_NAME: "pr-${{ github.run_id }}-cloudflare"
DOMAIN_SUFFIX: "test.stackhead.io"
# You should not need to change anything below.
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: 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
steps:
- uses: actions/checkout@v2
- name: Remove Python 2 and old Ansible 2.9 version
run: sudo apt purge python ansible -y
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install Ansible v2.10.3 (GH actions currently uses 2.9)
run: pip install ansible==2.10.3
- name: Print Ansible and Python version
run: ansible --version && python --version
- uses: webfactory/ssh-agent@v0.4.1
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 }}
- 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 }}'
container: '${{ env.CONTAINER }}'
dns: '${{ env.DNS }}'
dns_cloudflare_apitoken: '${{ secrets.CLOUDFLARE_TOKEN }}'
rolename: '${{ env.ROLE_NAME }}'
- 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 }}