Skip to content

Instantly share code, notes, and snippets.

@ostark
Last active March 27, 2017 10:59
Show Gist options
  • Save ostark/372d438a58abd0e50569be60fe5725ca to your computer and use it in GitHub Desktop.
Save ostark/372d438a58abd0e50569be60fe5725ca to your computer and use it in GitHub Desktop.
<?php
/**
* Deploy sensitive files (laravel/passport example)
*
* OAUTH_PRIVATE_KEY (content of oauth-private.key) and OAUTH_PUB_KEY (content of oauth-public.key) must be stored in App Secrets
* https://help.fortrabbit.com/secrets
*
* Call this script post deployment (fortrabbit.yml)
* https://help.fortrabbit.com/deployment-file-v2#toc-a-minimal-example
*/
// Read secrets json >> array
$secrets = json_decode(file_get_contents(getenv('APP_SECRETS')), true);
// Target path
$path = '/srv/app/' . getenv('APP_NAME') . '/htdocs/storage';
// Key contents
$privateKey = $secrets['CUSTOM']['OAUTH_PRIVATE_KEY'];
$pubKey = $secrets['CUSTOM']['OAUTH_PUB_KEY'];
// Write private key
file_put_contents("$path/oauth-private.key", $privateKey);
// Write pub key
file_put_contents("$path/oauth-public.key", $pubKey);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment