- If you're missing GitHub Twitter hook when using GitLab, you just found a solution.
- Log into https://dev.twitter.com/apps
- Click on Create a new application.
- Fill out everything needed and click on Create your Twitter application.
- Now in Settings tab, set Access: to Read and Write and save it.
- Keep this page open or copy all the tokens and keys from Details tab. You'll need them in a while.
- If you don't have account on bit.ly, create one.
- Log into your account, and copy your Api Key from Settings tab.
- Clone this repository:
git clone git@github.com:SmartMedia/gitlab-hook.git
- Create Heroku Cedar application:
heroku create <APP_NAME> --stack cedar
- Setup variables based on your Twitter Details and Bitly Settings tab:
- For
GITLAB_ACCESS_TOKEN
use some random string.
heroku config:add \
GITLAB_ACCESS_TOKEN='' \
BITLY_USERNAME='' \
BITLY_API_KEY='' \
TWITTER_CONSUMER_KEY='' \
TWITTER_CONSUMER_SECRET='' \
TWITTER_OAUTH_TOKEN='' \
TWITTER_OAUTH_TOKEN_SECRET=''
- Put your
- If you want to test localy, setup the same variables used by application in all
*.yml.erb
files inconfig
directory. git push heroku
- Open your project.
- Select Hooks tab.
- Fill out URL of your Heroku app with
access_token
parameter. (eg.http://<APP_NAME>.herokuapp.com/?access_token=<GITLAB_ACCESS_TOKEN>
) - Press "Test Hook"
- Enjoy your Twitter timeline.
- SSH to your GitLab server. Navigate to gitlab directory and run
rails c production
# If you already have this hook on some project, you can use url = WebHook.first.url
url = 'http://<APP_NAME>.herokuapp.com/?access_token=<GITLAB_ACCESS_TOKEN>'
Project.all.each do |project|
project.web_hooks << WebHook.create(url: url) if project.web_hooks.empty?
end