<commit_before>{% set app_name = 'ocw-build' %}
{% set env_settings = salt.cp.get_url("https://raw.githubusercontent.com/mitodl/salt-ops/main/salt/environment_settings.yml", dest=None)|load_yaml %}
{% set ENVIRONMENT = salt.grains.get('environment', 'applications-qa') %}
{% set env_data = env_settings.environments[ENVIRONMENT] %}
{% set business_unit = env_data.purposes[app_name].business_unit %}
{% set server_domain_names = env_data.purposes[app_name].domains %}
{% set env_map = {
    'rc-apps': {
        'target_branch': 'release-candidate'
    },
    'production-apps': {
        'target_branch': 'release'
    }
} %}

caddy:
  install_from_repo: False
  custom_build:
    os: linux
    arch: amd64
    plugins:
      - github.com/abiosoft/caddy-exec
      - github.com/abiosoft/caddy-hmac
      - github.com/abiosoft/caddy-json-parse
  config:
    apps:
      http:
        servers:
          ocw_build:
            listen:
              - ':443'
            routes:
              - match:
                  - host: {{ server_domain_names|to_json }}
                handle:
                - handler: subroute
                  routes:
                  - match:
                      - header_regexp:
                          X-Hub-Signature:
                            pattern: '[a-z0-9]+\=([a-z0-9]+)'
                        path:
                          - /build-content-webhook
                    handle:
                      - handler: subroute
                        routes:
                          - handle:
                              - algorithm: sha1
                                handler: hmac
                                secret: __vault__:gen_if_missing:secret-operations/global/github-hmac-secret-string>data>value
                          - handle:<commit_msg>Fix jinja filter name (tojson, not to_json)<commit_after>{% set app_name = 'ocw-build' %}
{% set env_settings = salt.cp.get_url("https://raw.githubusercontent.com/mitodl/salt-ops/main/salt/environment_settings.yml", dest=None)|load_yaml %}
{% set ENVIRONMENT = salt.grains.get('environment', 'applications-qa') %}
{% set env_data = env_settings.environments[ENVIRONMENT] %}
{% set business_unit = env_data.purposes[app_name].business_unit %}
{% set server_domain_names = env_data.purposes[app_name].domains %}
{% set env_map = {
    'rc-apps': {
        'target_branch': 'release-candidate'
    },
    'production-apps': {
        'target_branch': 'release'
    }
} %}

caddy:
  install_from_repo: False
  custom_build:
    os: linux
    arch: amd64
    plugins:
      - github.com/abiosoft/caddy-exec
      - github.com/abiosoft/caddy-hmac
      - github.com/abiosoft/caddy-json-parse
  config:
    apps:
      http:
        servers:
          ocw_build:
            listen:
              - ':443'
            routes:
              - match:
                  - host: {{ server_domain_names|tojson }}
                handle:
                - handler: subroute
                  routes:
                  - match:
                      - header_regexp:
                          X-Hub-Signature:
                            pattern: '[a-z0-9]+\=([a-z0-9]+)'
                        path:
                          - /build-content-webhook
                    handle:
                      - handler: subroute
                        routes:
                          - handle:
                              - algorithm: sha1
                                handler: hmac
                                secret: __vault__:gen_if_missing:secret-operations/global/github-hmac-secret-string>data>value
                          - handle:
{'fraction_non_alphanumeric': 0.1141050316194666, 'fraction_numerical': 0.005499037668408029, 'mean_word_length': 1.3918474687705458, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7190323', 'n_tokens_mistral': 1110, 'n_tokens_neox': 1043, 'n_words': 155}