Skip to content

Commit 9871708

Browse files
author
Thomas Osowski
committed
Switch to env var for private key
1 parent f203186 commit 9871708

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

app/ruby/app-issue-creator/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ This is the sample project that walks through creating a GitHub App and configur
1818

1919
Install the required Ruby Gems by entering `bundle install` on the command line.
2020

21+
Set environment variables `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY`. For example, run the following to store the private key to an environment variable: `GITHUB_APP_PRIVATE_KEY="$(less private-key.pem)"`
22+
2123
To start the server, type `ruby server.rb` on the command line.
2224

2325
The [sinatra server](http://www.sinatrarb.com/) will be running at `localhost:4567`.

app/ruby/app-issue-creator/server.rb

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,13 @@
66

77
begin
88
GITHUB_APP_ID = ENV.fetch("GITHUB_APP_ID")
9-
path_to_pem = './private-key.pem'
10-
GITHUB_PRIVATE_KEY = File.read(path_to_pem)
9+
GITHUB_PRIVATE_KEY = ENV.fetch("GITHUB_APP_PRIVATE_KEY")
1110
rescue KeyError
1211
$stderr.puts "To run this script, please set the following environment variables:"
1312
$stderr.puts "- GITHUB_APP_ID: GitHub App ID"
14-
exit 1
15-
rescue Exception => e
16-
$stderr.puts "To run this script, please copy your App's private key to this directory"
17-
$stderr.puts " and rename it to `private_key.pem`"
13+
$stderr.puts "- GITHUB_APP_PRIVATE_KEY: GitHub App Private Key"
1814
exit 1
1915
end
20-
2116
@client = nil
2217

2318
# Webhook listener
@@ -72,7 +67,7 @@ def get_app_repositories
7267
def create_issues(repositories, sender_username)
7368
repositories.each do |repo|
7469
begin
75-
@client.create_issue(repo, "#{sender_username} created new app!", "Added GitHub App")
70+
@client.create_issue(repo, "#{sender_username} added new app!", "Added GitHub App")
7671
rescue
7772
puts "Issues is disabled for this repository"
7873
end

0 commit comments

Comments
 (0)