Jump to content

Extension:PageToGitHub

From mediawiki.org
MediaWiki extensions manual
PageToGitHub
Release status: stable
Implementation Data extraction, Special page
Description Automatically transfers code from a MediaWiki wiki to GitHub
Author(s) Luca Mauri
Latest version 2.0.0 (2023-12-01)
Compatibility policy Snapshots releases along with MediaWiki. Master is not backward compatible.
MediaWiki 1.35+
PHP 7.4+
Composer lucamauri/page-to-github
License GNU General Public License 3.0 or later
Download
Module
  • $wgP2GAuthToken
  • $wgP2GIgnoreMinor
  • $wgP2GKeyword
  • $wgP2GAddKeyword
  • $wgP2GNameSpace
  • $wgP2GOwner
  • $wgP2GRepo

PageToGitHub, P2G in short, is a MediaWiki extension to automatically transfer code from a MediaWiki wiki to GitHub.

Install

[edit]

Easiest way to install the extension is using Composer: it will automatically resolve all the dependencies and install them as well.

Add the require configuration as in the following example to the composer.local.json at the root of your mediawiki installation, or create the file if it does not exist yet:

{
    "require": {
        "lucamauri/page-to-github": "~2.0"
    },
    "extra": {
        "merge-plugin": {
            "include": [
            ]
        }
    },
    "config": {
    }
}

and, in a command prompt, run Composer in the root of your mediawiki installation:

composer install --no-dev

Add the following code near the rest of the extensions loading in the site’s LocalSettings.php:

wfLoadExtension('PageToGitHub');

Below this line, add the configuration parameters as explained below in Configuration section.

Configuration

[edit]

In the LocalSettigs.php file add:

$wgP2GAuthToken = 'GitHub-Token';
$wgP2GIgnoreMinor = true;
$wgP2GKeyword = 'Keyword';
$wgP2GAddKeyword = true;
$wgP2GNameSpace = 'Module';
$wgP2GOwner = 'Project-Or-Person';
$wgP2GRepo = 'Name-Of-Your-Repository';

$wgP2GAuthToken

[edit]

The GitHub token needed to authenticate and made modification the the repository. You can generate one in your GitHub account in Settings > Developer settings > Personal access tokens

$wgP2GIgnoreMinor

[edit]

If empty or set as true the revision is not pushed to GitHub if is marked as Minor

$wgP2GKeyword

[edit]

An optional keyword to check into the page. When present, P2G will not upload pages if the keyword is not written in the page. If the parameter is omitted, P2G will upload all pages in the Namespace specified above.

$wgP2GAddKeyword

[edit]

An optional boolean parameter: when set to true the word defined in $wgP2GKeyword is added before the name of the page to form the filename.

$wgP2GNameSpace

[edit]

P2G will upload pages only belonging to the namespace spedified in this variable

$wgP2GOwner

[edit]

The Person or Organization owner of the repository

$wgP2GRepo

[edit]

The name of the repository where the code must be uploaded

Troubleshoot

[edit]

To read detailed logging messages, you can intercept the log group named PageToGitHub: for instance with the following configuration into LocalSetting.php:

$wgShowExceptionDetails = true;
$wgDebugLogGroups['PageToGitHub'] = "/var/log/mediawiki/PageToGitHub-{$wgDBname}.log";