Created
November 17, 2019 17:29
-
-
Save swalkinshaw/aab8ceff6001c65519e4334574a4f111 to your computer and use it in GitHub Desktop.
Trellis + Sentry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* composer require sentry/sentry-sdk | |
*/ | |
use Sentry; | |
Env::init(); | |
// Bedrock application config... | |
if (env('SENTRY_DSN')) { | |
Sentry\init([ | |
'dsn' => env('SENTRY_DSN'), | |
'release' => env('GIT_SHA'), | |
'environment' => env('WP_ENV'), | |
'error_types' => E_ALL & ~E_NOTICE & ~E_DEPRECATED, | |
]); | |
Sentry\configureScope(function (Sentry\State\Scope $scope): void { | |
$scope->setTag('trellis_version', env('RELEASE_VERSION')); | |
}); | |
} | |
// ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sentry deployment tasks | |
# | |
# I'm calling this from `finalize-after.yml` deploy-hook like: | |
# - import_tasks: "{{ playbook_dir }}/deploy-hooks/plugins/sentry.yml" | |
# | |
# You could also just include directly | |
- name: Create Sentry release | |
uri: | |
url: /api/0/organizations/{{ sentry_organization }}/releases/ | |
method: POST | |
status_code: 201 | |
headers: | |
Content-Type: "application/json" | |
Accept: "application/json" | |
Authorization: "Bearer {{ vault_sentry_token }}" | |
body_format: json | |
body: | |
project: ["{{ sentry_project }}"] | |
ref: "{{ git_clone.after }}" | |
version: "{{ deploy_helper.new_release }}" | |
- name: Create Sentry deploy | |
uri: | |
url: /api/0/organizations/{{ sentry_organization }}/releases/{{ deploy_helper.new_release }}/deploys/ | |
method: POST | |
status_code: 201 | |
headers: | |
Content-Type: "application/json" | |
Accept: "application/json" | |
Authorization: "Bearer {{ vault_sentry_token }}" | |
body_format: json | |
body: | |
environment: ["{{ project.env }}"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git roles/deploy/vars/main.yml roles/deploy/vars/main.yml | |
index aea2f70..7015d34 100644 | |
--- roles/deploy/vars/main.yml | |
+++ roles/deploy/vars/main.yml | |
@@ -7,5 +7,7 @@ wordpress_env_defaults: | |
wp_home: "{{ project.ssl.enabled | default(false) | ternary('https', 'http') }}://{{ project.site_hosts | map(attribute='canonical') | first }}" | |
wp_siteurl: "{{ project.ssl.enabled | default(false) | ternary('https', 'http') }}://{{ project.site_hosts | map(attribute='canonical') | first }}/wp" | |
domain_current_site: "{{ project.site_hosts | map(attribute='canonical') | first }}" | |
+ git_sha: "{{ git_clone.after }}" | |
+ release_version: "{{ deploy_helper.new_release }}" | |
site_env: "{{ wordpress_env_defaults | combine(vault_wordpress_env_defaults | default({}), project.env | default({}), vault_wordpress_sites[site].env) }}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add Sentry auth token to Vault | |
# Documentation: https://roots.io/trellis/docs/vault/ | |
vault_mysql_root_password: productionpw | |
# new | |
vault_sentry_token: "token" | |
# rest etc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment