Created
February 25, 2025 07:51
-
-
Save schacon/d179d65d802ea5d17d2e5804dd8f3d35 to your computer and use it in GitHub Desktop.
This file contains 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
*.yml.enc diff=encrypted |
This file contains 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 "encrypted"] | |
textconv = ~/bin/decrypt_creds |
This file contains 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
#! /usr/bin/env ruby | |
require 'active_support' | |
require 'active_support/encrypted_configuration' | |
require 'active_support/core_ext/hash/indifferent_access' | |
# get path from first paramater | |
credentials_path = ARGV[0] | |
match_data = credentials_path.match(%r{(\w+)\.yml\.enc}) | |
if match_data | |
env = match_data[1] | |
end | |
key_path = "#{Dir.pwd}/config/credentials/#{env}.key" | |
unless File.exist?(credentials_path) && File.exist?(key_path) | |
puts "Credentials or key file not found." | |
exit | |
end | |
encrypted_config = ActiveSupport::EncryptedConfiguration.new( | |
config_path: credentials_path, | |
key_path: key_path, | |
env_key: "RAILS_MASTER_KEY", | |
raise_if_missing_key: true | |
) | |
puts encrypted_config.read |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment