Skip to content
You're viewing an older version of this GitHub Action. Do you want to see the latest version instead?
arrow-up-right

GitHub Action

Gadget deploy

v1.0.0

Gadget deploy

arrow-up-right

Gadget deploy

Deploy user scripts or gadgets to Wikimedia sites

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Gadget deploy

uses: wikimedia-gadgets/[email protected]

Learn more about this action in wikimedia-gadgets/deploy-action

Choose a version

deploy-action

GitHub Action to automate user script and gadget deployments to Wikimedia wikis.

Usage

  • Setup either a BotPassword or an owner-only OAuth2 credentials for your user account, which will get used for updating the script pages.

    • Make sure the grant to allow editing your user CSS/JSON/JavaScript is checked.
  • Save the credentials to GitHub Secrets in your repo (either the OAUTH2_TOKEN, or the USERNAME and PASSWORD).

  • Add a file deploy.yml under .github/workflows, with the content:

name: 'deploy'
on:
  push:
    branches:
      - master
  workflow_dispatch:

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      # Run build and ensure tests are passing before deployment
      - run: npm run --if-present build
      - run: npm run --if-present test
      - uses: wikimedia-gadgets/deploy-action@v1
        with:
          paths: 'src/myscript.js User:SD0001/myscript.js'
          apiUrl: 'https://en.wikipedia.org/w/api.php'
          
          oauth2Token: ${{ secrets.OAUTH2_TOKEN }}
          ### OR ###
          username: ${{ secrets.USERNAME }}
          password: ${{ secrets.PASSWORD }}

This action as written above will be triggered every time a commit is pushed to master branch. For alternative trigger mechanisms (such as triggering when a release is published), refer to GitHub docs.

Specifying paths

Specifying single path:

paths: 'src/myscript.js User:SD0001/myscript.js'

Format is repo path wiki page title. Note that the repo path itself cannot contain spaces.

Specifying multiple paths:

paths: |
  src/myscript.js User:SD0001/myscript.js
  src/mystyle.css User:SD0001/mystyle.css

Specifying multiple paths via wildcards:

paths: |
  src/*.js User:SD0001/*.js
  src/*.css User:SD0001/*.css