diff --git a/.github/workflows/protect new wiki modules.yml b/.github/workflows/protect new wiki.yml similarity index 63% rename from .github/workflows/protect new wiki modules.yml rename to .github/workflows/protect new wiki.yml index 6bb1caafa9a..1fc47e9b90a 100644 --- a/.github/workflows/protect new wiki modules.yml +++ b/.github/workflows/protect new wiki.yml @@ -17,14 +17,27 @@ jobs: - uses: actions/checkout@v6 - name: Setup Python + id: setup uses: actions/setup-python@v6 with: python-version: '3.14' - name: Install Python Dependency + id: dependencies run: pip install requests + - name: Template 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 }} + WIKI_TO_PROTECT: ${{ github.event.inputs.wiki }} + PYTHONUNBUFFERED: 1 + run: python3 ./scripts/protect_templates.py + - name: Lua Protect + #if: steps.setup.outcome == 'success' && steps.dependencies.outcome == 'success' env: WIKI_USER: ${{ secrets.LP_BOTUSER }} WIKI_PASSWORD: ${{ secrets.LP_BOTPASSWORD }} diff --git a/.github/workflows/protect new wiki templates.yml b/.github/workflows/protect page across wikis.yml similarity index 74% rename from .github/workflows/protect new wiki templates.yml rename to .github/workflows/protect page across wikis.yml index 3b1542f5a2b..8d5030ece43 100644 --- a/.github/workflows/protect new wiki templates.yml +++ b/.github/workflows/protect page across wikis.yml @@ -1,10 +1,10 @@ -name: Protect newly set up wiki +name: Protect page across wikis on: workflow_dispatch: inputs: - wiki: - description: 'Wiki to set up' + page: + description: 'Page to protect (prefix with namespace and use underscores!)' required: true jobs: @@ -30,6 +30,6 @@ jobs: WIKI_PASSWORD: ${{ secrets.LP_BOTPASSWORD }} WIKI_UA_EMAIL: ${{ secrets.LP_UA_EMAIL }} WIKI_BASE_URL: ${{ secrets.LP_BASE_URL }} - WIKI_TO_PROTECT: ${{ github.event.inputs.wiki }} + PAGE_TO_PROTECT: ${{ github.event.inputs.page }} PYTHONUNBUFFERED: 1 - run: python3 ./scripts/protect_templates.py + 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..7b27075f314 --- /dev/null +++ b/scripts/protect_page_across_wikis.py @@ -0,0 +1,24 @@ +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: # commons case + protect_non_existing_page(PAGE_TO_PROTECT, wiki) + print("::endgroup::") + handle_protect_errors() + + +if __name__ == "__main__": + main()