zuul-jobs/roles/trigger-readthedocs/tasks/main.yaml

45 lines
1.6 KiB
YAML

- name: Check for webhook id
fail:
msg: You must define the webhook id. Get this from the webhook info page on RTD
when: rtd_webhook_id is not defined
- name: Check for an authentication type
fail:
msg: Must set either rtd_credentials.username or rtd_credentials.integration_token
when: (rtd_credentials.username is not defined) and (rtd_credentials.integration_token is not defined)
- name: Upload to RTD
when: rtd_credentials.username is defined
block:
- name: Require password
fail:
msg: password is required when using rtd_credentials.username
when: rtd_credentials.password is not defined
- name: Trigger readthedocs build webhook via authentication
uri:
method: POST
url: 'https://readthedocs.org/api/v2/webhook/{{ rtd_project_name }}/{{ rtd_webhook_id }}/'
user: '{{ rtd_credentials.username }}'
password: '{{ rtd_credentials.password }}'
# NOTE(ianw): testing it seems the API doesn't respond with
# 401 so this is required
force_basic_auth: yes
# avoid logging any credentials
no_log: true
- name: Trigger RTD docs
when: rtd_credentials.integration_token is defined and
rtd_credentials.username is not defined
block:
- name: Trigger readthedocs build webhook via token
uri:
method: POST
url: 'https://readthedocs.org/api/v2/webhook/{{ rtd_project_name }}/{{ rtd_webhook_id }}/'
body_format: form-urlencoded
body:
token: '{{ rtd_credentials.integration_token }}'
follow_redirects: all
# avoid logging any credentials
no_log: true