GitHub Action
Gadget deploy
GitHub Action to automate user script and gadget deployments to Wikimedia wikis.
-
Setup either a BotPassword or an owner-only OAuth2 credential 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
- name: Deploy to Wikipedia
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 }}
# Optional, defaults to "Updating from repo at $BRANCH ($SHA)"
# If provided, $BRANCH will be expanded to branch name, $SHA to 8-character SHA1,
# and $SOURCE to the source file path.
# You can also use values from the context (https://docs.github.com/en/actions/learn-github-actions/contexts#github-context)
# such as ${{github.repository}} or ${{github.actor}}
editSummary: ''
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 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