Skip to content

Instantly share code, notes, and snippets.

@Log1x
Forked from swalkinshaw/application.php
Last active April 3, 2020 20:38
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Log1x/a5b9cf9ab6320c3a4f3e66b0bfea3dd4 to your computer and use it in GitHub Desktop.
Save Log1x/a5b9cf9ab6320c3a4f3e66b0bfea3dd4 to your computer and use it in GitHub Desktop.
Trellis + Sentry
<?php
/**
* composer require sentry/sentry-sdk
*/
Env::init();
// ...
if (env('SENTRY_DSN') && env('WP_ENV') !== 'development') {
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'));
});
}
// ...
# 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: https://sentry.io/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:
projects: ["{{ sentry_project }}"]
ref: "{{ git_clone.after }}"
version: "{{ deploy_helper.new_release }}"
- name: Create Sentry deploy
uri:
url: https://sentry.io/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: "{{ env }}"
vault_mysql_root_password: ...
vault_sentry_token: xxxxxxxxxxxxxxxxx
sentry_organization: example
sentry_project: example
vault_wordpress_sites:
example.dev:
env:
sentry_dsn: https://xxxxx@sentry.io/xxxxx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment