From 04c167fde7c0fb3cbb2650edd2d343f58c93d9c1 Mon Sep 17 00:00:00 2001 From: taskirel <75871323+taskylizard@users.noreply.github.com> Date: Sun, 9 Apr 2023 16:30:28 +0000 Subject: [PATCH] feat: automate single-page --- .github/single-page.py | 25 +++++++++++++++++++++++ .github/workflows/single-page.yml | 34 +++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 .github/single-page.py create mode 100644 .github/workflows/single-page.yml diff --git a/.github/single-page.py b/.github/single-page.py new file mode 100644 index 000000000..a8240b226 --- /dev/null +++ b/.github/single-page.py @@ -0,0 +1,25 @@ +import os +import glob +import time +import re + +def output(): + read = glob.glob("*.md") + content = "" + for file in read: + if file != "single-page.md" and file != "README.md": + with open(file, "r") as f: + content += f.read() + return content + +def main(): + content = output() + with open("single-page", "w") as file: + file.write(content) + + +if __name__ == "__main__": + s = time.perf_counter() + main() + elapsed = time.perf_counter() - s + print(f"{__file__} executed in {elapsed:0.2f} seconds.") diff --git a/.github/workflows/single-page.yml b/.github/workflows/single-page.yml new file mode 100644 index 000000000..822272cf7 --- /dev/null +++ b/.github/workflows/single-page.yml @@ -0,0 +1,34 @@ +name: Update Single Page + +on: + workflow_dispatch: + schedule: + - cron: '0 */2 * * *' + +jobs: + update: + name: Update Single Page + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@v2 + + - name: Setup Python + uses: actions/setup-python@v4 + with: + python-version: '3.10' + + - name: Configure Git + run: | + git config user.name "taskylizard" + git config user.email "75871323+taskylizard@users.noreply.github.com" + + - name: Update + run: | + python .github/single-page.py + git add . + git commit -m "♻️ update single page" + git push \ No newline at end of file