From 42f5f92eabaced6a8a7871a6689f4cad10c29313 Mon Sep 17 00:00:00 2001 From: yusancky Date: Sun, 31 Mar 2024 14:14:20 +0800 Subject: [PATCH 1/3] Configure DNS --- .github/workflows/AllUp.yml | 12 ++++++------ AllUp_utils/wiki.py | 13 +++++++++---- PR_preview.md | 2 +- main.py | 2 +- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/.github/workflows/AllUp.yml b/.github/workflows/AllUp.yml index 5e493b6..c9305ca 100644 --- a/.github/workflows/AllUp.yml +++ b/.github/workflows/AllUp.yml @@ -30,18 +30,18 @@ jobs: cache: 'pip' - name: Install Python Dependencies run: pip install -r requirements.txt + - name: Configure DNS + run: | + sudo systemd-resolve --set-dns=114.114.114.114 --set-dns=223.6.6.6 + cat /run/systemd/resolve/resolv.conf + sudo systemctl restart systemd-resolved.service - name: Main run: python main.py env: + BOT_PASSWORD: ${{ secrets.BOT_PASSWORD }} GITHUB_EVENT_NAME: ${{ github.event_name }} GITHUB_REF: ${{ github.ref }} GITHUB_REPOSITORY_OWNER: ${{ github.repository_owner }} - - uses: actions4git/setup-git@v1 - - run: | - git checkout --orphan artifact/${{ github.ref }} - git add AllUp.wikitext - git commit -m "Update data" - git push --force origin artifact/${{ github.ref }} - name: Preview on Pull Request if: ${{ github.event_name == 'pull_request' }} uses: thollander/actions-comment-pull-request@v2.4.2 diff --git a/AllUp_utils/wiki.py b/AllUp_utils/wiki.py index 2aff999..8b77fff 100644 --- a/AllUp_utils/wiki.py +++ b/AllUp_utils/wiki.py @@ -29,7 +29,12 @@ def pull(title : str,split_line = False): except: print(f'You do not have permission to get password.\nREF: {environ["GITHUB_REF"]}\nREPO_OWNER: {environ["GITHUB_REPOSITORY_OWNER"]}') -def push(title : str,content_id : str,content : str): - open(f'{title}.wikitext', 'w').write(content) - if PR_TEST(): - print(f'### {content_id}\n\n```go\n{content}\n```\n\n',file = open('PR_preview.md','a')) +def push(content : str): + if MAIN_REPO_BRANCH() or PR_TEST(): + try: + wiki = Wiki('sat.huijiwiki.com', '雨伞CKY', environ['BOT_PASSWORD']) + wiki.edit('模板:AllUp',content,'Edit via AllUp-Satwiki') + except: + open(f'{title}.wikitext', 'w').write(content) + elif PR_TEST(): + print(f'```go\n{content}\n```\n\n',file = open('PR_preview.md','a')) diff --git a/PR_preview.md b/PR_preview.md index 4d968c3..0f177ef 100644 --- a/PR_preview.md +++ b/PR_preview.md @@ -1,4 +1,4 @@ ## Preview -After _current_ modification of the PR, the program builds the main and TSS content as shown below. The content won't be uploaded to Satwiki before the PR is merged. +After _current_ modification of the PR, the program builds the content as shown below. The content won't be uploaded to Satwiki before the PR is merged. diff --git a/main.py b/main.py index c0176f6..de2ccf0 100644 --- a/main.py +++ b/main.py @@ -136,4 +136,4 @@ def make(id): for dataset in ['t'] + [str(i + 1) for i in range(4)] + ['#default']: AllUp_data[dataset] = make(dataset) AllUp_content = f'{AllUp_utils.wikitext.build_switch(AllUp_data)}[[Category:模板]]{{{{documentation}}}}' - AllUp_utils.wiki.push('AllUp','MAIN',AllUp_content) + AllUp_utils.wiki.push(AllUp_content) From 8b0847d7c5ab5df9e72bfe9d1f5b39864b9e0ffc Mon Sep 17 00:00:00 2001 From: yusancky Date: Wed, 3 Apr 2024 21:32:26 +0800 Subject: [PATCH 2/3] Use `resolvectl` --- .github/workflows/AllUp.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/AllUp.yml b/.github/workflows/AllUp.yml index c9305ca..b2df47d 100644 --- a/.github/workflows/AllUp.yml +++ b/.github/workflows/AllUp.yml @@ -32,9 +32,9 @@ jobs: run: pip install -r requirements.txt - name: Configure DNS run: | - sudo systemd-resolve --set-dns=114.114.114.114 --set-dns=223.6.6.6 - cat /run/systemd/resolve/resolv.conf - sudo systemctl restart systemd-resolved.service + sudo systemctl enable --now systemd-resolved + sudo resolvectl dns --global 114.114.114.114 + resolvectl status - name: Main run: python main.py env: From 99d5805fe06d797fea617578062ba3492404f79b Mon Sep 17 00:00:00 2001 From: yusancky Date: Sat, 6 Apr 2024 13:53:25 +0800 Subject: [PATCH 3/3] Update AllUp.yml --- .github/workflows/AllUp.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/AllUp.yml b/.github/workflows/AllUp.yml index b2df47d..942182f 100644 --- a/.github/workflows/AllUp.yml +++ b/.github/workflows/AllUp.yml @@ -30,11 +30,6 @@ jobs: cache: 'pip' - name: Install Python Dependencies run: pip install -r requirements.txt - - name: Configure DNS - run: | - sudo systemctl enable --now systemd-resolved - sudo resolvectl dns --global 114.114.114.114 - resolvectl status - name: Main run: python main.py env: