Skip to content

Commit 2d58d1c

Browse files
authored
feat: Add action to protect a page across all wikis (#7203)
* feat: Add action to protect a page across all wikis * Create protect page across wikis.yml * Update protect page across wikis.yml
1 parent f973f30 commit 2d58d1c

2 files changed

Lines changed: 60 additions & 0 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Protect page across wikis
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
page:
7+
description: 'Page to protect (prefix with namespace!)'
8+
required: true
9+
10+
jobs:
11+
protect:
12+
if: github.ref_name == github.event.repository.default_branch
13+
name: Protect a given page across all wikis
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- uses: actions/checkout@v6
18+
19+
- name: Setup Python
20+
uses: actions/setup-python@v6
21+
with:
22+
python-version: '3.14'
23+
24+
- name: Install Python Dependency
25+
run: pip install requests
26+
27+
- name: Page Protect
28+
env:
29+
WIKI_USER: ${{ secrets.LP_BOTUSER }}
30+
WIKI_PASSWORD: ${{ secrets.LP_BOTPASSWORD }}
31+
WIKI_UA_EMAIL: ${{ secrets.LP_UA_EMAIL }}
32+
WIKI_BASE_URL: ${{ secrets.LP_BASE_URL }}
33+
PAGE_TO_PROTECT: ${{ github.event.inputs.page }}
34+
PYTHONUNBUFFERED: 1
35+
run: python3 ./scripts/protect_page_across_wikis.py
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import os
2+
3+
from deploy_util import get_wikis
4+
from protect_page import (
5+
protect_non_existing_page,
6+
protect_existing_page,
7+
handle_protect_errors,
8+
)
9+
10+
PAGE_TO_PROTECT = os.getenv("PAGE_TO_PROTECT")
11+
12+
13+
def main():
14+
for wiki in get_wikis():
15+
print(f"::group::Checking {wiki}:{PAGE_TO_PROTECT}")
16+
if wiki == "commons":
17+
protect_existing_page(PAGE_TO_PROTECT, wiki)
18+
else:
19+
protect_non_existing_page(PAGE_TO_PROTECT, wiki)
20+
print("::endgroup::")
21+
handle_protect_errors()
22+
23+
24+
if __name__ == "__main__":
25+
main()

0 commit comments

Comments
 (0)