- 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 # NOTE(ianw): 2024-11-08 the URI module fails here in mysterious # -- seeminly platform dependent -- ways; see # https://github.com/readthedocs/readthedocs.org/issues/11753 # We call curl directly to work around this ansible.builtin.command: >- curl -X POST -u {{ rtd_credentials.username }}:{{ rtd_credentials.password }} 'https://readthedocs.org/api/v2/webhook/{{ rtd_project_name }}/{{ rtd_webhook_id }}/' # 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