diff --git a/.github/workflows/protect page across wikis.yml b/.github/workflows/protect page across wikis.yml new file mode 100644 index 00000000000..6f9674247e8 --- /dev/null +++ b/.github/workflows/protect page across wikis.yml @@ -0,0 +1,35 @@ +name: Protect page across wikis + +on: + workflow_dispatch: + inputs: + page: + description: 'Page to protect (prefix with namespace!)' + required: true + +jobs: + protect: + if: github.ref_name == github.event.repository.default_branch + name: Protect a given page across all wikis + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v6 + + - name: Setup Python + uses: actions/setup-python@v6 + with: + python-version: '3.14' + + - name: Install Python Dependency + run: pip install requests + + - name: Page Protect + env: + WIKI_USER: ${{ secrets.LP_BOTUSER }} + WIKI_PASSWORD: ${{ secrets.LP_BOTPASSWORD }} + WIKI_UA_EMAIL: ${{ secrets.LP_UA_EMAIL }} + WIKI_BASE_URL: ${{ secrets.LP_BASE_URL }} + PAGE_TO_PROTECT: ${{ github.event.inputs.page }} + PYTHONUNBUFFERED: 1 + run: python3 ./scripts/protect_page_across_wikis.py diff --git a/scripts/protect_page_across_wikis.py b/scripts/protect_page_across_wikis.py new file mode 100644 index 00000000000..43a49d42c32 --- /dev/null +++ b/scripts/protect_page_across_wikis.py @@ -0,0 +1,25 @@ +import os + +from deploy_util import get_wikis +from protect_page import ( + protect_non_existing_page, + protect_existing_page, + handle_protect_errors, +) + +PAGE_TO_PROTECT = os.getenv("PAGE_TO_PROTECT") + + +def main(): + for wiki in get_wikis(): + print(f"::group::Checking {wiki}:{PAGE_TO_PROTECT}") + if wiki == "commons": + protect_existing_page(PAGE_TO_PROTECT, wiki) + else: + protect_non_existing_page(PAGE_TO_PROTECT, wiki) + print("::endgroup::") + handle_protect_errors() + + +if __name__ == "__main__": + main()