Skip to content

Commit

Permalink
Place the github secrets in ~/.netrc
Browse files Browse the repository at this point in the history
which is a standard location and you will not commit them accidentally
  • Loading branch information
mvidner committed Jun 13, 2012
1 parent 2c3d431 commit 867597c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion github-scripts/github-create-email-hook
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ do
}
EOJSON

curl -s -u ${username}:${password} -X POST -d @${json} https://api.github.com/repos/${organization}/${repo}/hooks -o ${json}.result
curl -s -n -X POST -d @${json} https://api.github.com/repos/${organization}/${repo}/hooks -o ${json}.result
done


14 changes: 9 additions & 5 deletions github-scripts/github-disable-email-hook
Original file line number Diff line number Diff line change
@@ -1,15 +1,21 @@
#!/bin/bash
# When recovering the broken svn-git migration,
# we needed to temporarily disable the commit email notifications.

# Stop on errors.
set -e

# Check that ~/.netrc knows github
. github-secrets

organization="yast"
# http://zq1.de/bernhard/yast-broken-list.txt
# Get the list from http://zq1.de/bernhard/yast-broken-list.txt
repolist=`sed 's/^/yast-/' yast-broken-list.txt`

for repo in $repolist
do
echo -n $repo...
curl -f -s -u ${username}:${password} https://api.github.com/repos/${organization}/${repo}/hooks -o ${json}.list
curl -f -s -n https://api.github.com/repos/${organization}/${repo}/hooks -o ${json}.list
if [ $(grep '"id"' ${json}.list | wc -l) != 1 ]; then
echo "$repo has more than one hook. fix manually"
touch ${repo}.error
Expand All @@ -26,8 +32,6 @@ do
}
}
EOJSON
curl -f -s -u ${username}:${password} -X PATCH -d @${json} https://api.github.com/repos/${organization}/${repo}/hooks/$ID -o ${json}.result
curl -f -s -n -X PATCH -d @${json} https://api.github.com/repos/${organization}/${repo}/hooks/$ID -o ${json}.result
echo " OK"
done


13 changes: 10 additions & 3 deletions github-scripts/github-secrets
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
username="johndoe"
password="yourpassword"

# This file used to define the shell variables `username` and `password`
# but then they would show up in output of `ps`, `bash -x`...
# It is better to use `~/.netrc` which `curl -n` will use.
if ! grep -qs api.github.com ~/.netrc; then
echo "Set up your Github credentials first:"
echo " : >> ~/.netrc"
echo " chmod 600 ~/.netrc"
echo " echo 'machine api.github.com login USER password PASSWORD' >> ~/.netrc"
exit 1
fi

0 comments on commit 867597c

Please sign in to comment.