Help:Toolforge/Auto-update a tool from GitHub
Note: Use of this deployment method has risks. If your GitHub repository is compromised by a 3rd party, your live tool could be impacted. Please think carefully before proceeding. |
Overview
You can use GitHub's webhooks feature to automatically deploy any changes made on GitHub to Toolforge. With this setup, whenever a push is made to the repository on GitHub, the changes will be fetched to the Toolforge clone of the repository, without having to manually log in to the tool's account and running git pull
.
Using webhooks with Github
Introductory-level information about using webhooks with GitHub can be found here:
PHP tool hosted in $HOME/public_html
First, set up a webhook listener that runs "git pull" whenever it's accessed from GitHub:
ssh USER@login.toolforge.org
become MYTOOL
echo "<?php if(isset($_SERVER['HTTP_X_GITHUB_EVENT'])) { `git pull`; } ?>" > public_html/git-pull.php
Then, set up the webhook emitter on GitHub's side:
- Go to
https://github.com/USER/REPO/settings/hooks
and click the "Add webhook" button - In the "Payload URL" field, type
https://MYTOOL.toolforge.org/git-pull.php
- Save the hook (the remaining fields can be kept with the default values)
That's it! Now whenever you push commits to the repo on GitHub, the Toolforge clone will be automatically updated.
PHP tool hosted in $HOME/www/static
First, set up a webhook listener (in the non-static $HOME/public_html
directory) that runs "git pull" whenever it's accessed from GitHub:
ssh USER@login.toolforge.org
become MYTOOL
mkdir ~/public_html
echo "<?php if(isset($_SERVER['HTTP_X_GITHUB_EVENT'])) { `git -C ../www/static pull`; } ?>" > public_html/git-pull.php
webservice start
Then, set up the webhook emitter on GitHub's side:
- Go to
https://github.com/USER/REPO/settings/hooks
and click the "Add webhook" button - In the "Payload URL" field, type
https://MYTOOL.toolforge.org/git-pull.php
- Save the hook (the remaining fields can be kept with the default values)
That's it! Now whenever you push commits to the repo on GitHub, the Toolforge clone will be automatically updated.
Communication and support
We communicate and provide support through several primary channels. Please reach out with questions and to join the conversation.
Connect | Best for | |
---|---|---|
Phabricator Workboard | #Cloud-Services | Task tracking and bug reporting |
IRC Channel | #wikimedia-cloud connect | General discussion and support |
Mailing List | cloud@ | Information about ongoing initiatives, general discussion and support |
Announcement emails | cloud-announce@ | Information about critical changes (all messages mirrored to cloud@) |
News wiki page | News | Information about major near-term plans |
Cloud Services Blog | Clouds & Unicorns | Learning more details about some of our work |
Wikimedia Technology Blog | techblog.wikimedia.org | News and stories from the Wikimedia technical movement |