-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.yml
41 lines (41 loc) · 1.34 KB
/
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
###
# Create a GitHub deployment for project and set its status to pending.
# Requires close_deployment task to be added also to close deployment as
# a success.
###
- name: Create a GitHub deployment
block:
- name: Check for GitHub token, and fail if not present
fail:
msg: "Pass a GitHub API token to -e github_token or set in environment as ANSIBLE_GITHUB_TOKEN"
when: github_token == ""
- name: Create a deployment
uri:
url: '{{ deployments_endpoint }}'
body_format: json
method: POST
status_code: 201
body:
ref: '{{ gitref }}'
environment: '{{ deploy_environment }}'
description: '{{ deploy_description }}'
required_contexts: '{{ deploy_contexts }}'
auto_merge: false
headers:
Authorization: "token {{ github_token }}"
return_content: true
register: deployment
- name: Set status to in progress
uri:
url: '{{ deployment.json.url }}/statuses'
body_format: json
method: POST
status_code: 201
body:
state: "pending"
description: "Deployment in progress"
headers:
Authorization: "token {{ github_token }}"
when: not staging
# No rescue because again, if either of these fail, the error status will
# likely also fail out.