From 755ad0bf1510641a8f88d95283a3e2443486aedc Mon Sep 17 00:00:00 2001 From: Sina Atalay Date: Tue, 16 Jul 2024 14:14:30 +0300 Subject: [PATCH] workflows: create `update-files.yaml` workflow --- .github/workflows/publish.yaml | 54 +++-------------------------- .github/workflows/test.yaml | 5 +-- .github/workflows/update-files.yaml | 54 +++++++++++++++++++++++++++++ 3 files changed, 62 insertions(+), 51 deletions(-) create mode 100644 .github/workflows/update-files.yaml diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index 85dff508..ad143a1c 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -24,14 +24,14 @@ jobs: - uses: actions/checkout@v4 with: submodules: recursive - + - name: Set up Python 3.12 uses: actions/setup-python@v5 with: python-version: "3.12" - name: Install Hatch - uses: pypa/hatch@install + uses: pypa/hatch@install - name: Check if the release tag matches the version uses: samuelcolvin/check-python-version@v4.1 @@ -45,50 +45,6 @@ jobs: - name: Upload package to PyPI uses: pypa/gh-action-pypi-publish@release/v1 - update_files: - name: Update schema.json, examples, and entry figures - runs-on: ubuntu-latest - needs: [publish] - - permissions: - contents: write - - steps: - - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Set up Python 3.12 - uses: actions/setup-python@v5 - with: - python-version: "3.12" - - - name: Install Hatch - uses: pypa/hatch@install - - - name: Set Git credentials - run: | - git config --global user.name "${{ github.actor }}" - git config --global user.email "${{ github.actor }}@users.noreply.github.com" - - - name: Update schema.json - run: | - hatch run docs:update-schema - git add schema.json - git commit -m "docs: update schema.json" - - - name: Update `examples` folder - run: | - hatch run docs:update-examples - git add examples/* - git commit -m "docs: update examples" - - - name: Update entry figures - run: | - hatch run docs:update-entry-figures - git add docs/assets/**/*.png - git commit -m "docs: update entry figures" - - - name: Push changes - run: | - git push origin HEAD:main + call_update_files_workflow: + name: Update files + uses: ./.github/workflows/update-files.yaml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index d949c97a..e0ac4d6e 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -7,6 +7,7 @@ on: pull_request: branches: ["main", "dev"] workflow_call: # to make the workflow triggerable from other workflows (publish.yaml) + workflow_dispatch: # to make the workflow triggerable manually # The workflow: jobs: @@ -51,7 +52,7 @@ jobs: uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - + - name: Install Hatch uses: pypa/hatch@install @@ -84,7 +85,7 @@ jobs: - name: Download coverage files uses: actions/download-artifact@v4 with: - pattern: coverage-* # download all the uploaded coverage reports + pattern: coverage-* # download all the uploaded coverage reports path: coverage merge-multiple: true # download them in the same folder diff --git a/.github/workflows/update-files.yaml b/.github/workflows/update-files.yaml new file mode 100644 index 00000000..48b1f21f --- /dev/null +++ b/.github/workflows/update-files.yaml @@ -0,0 +1,54 @@ +name: Update files + +# GitHub events that triggers the workflow: +on: + workflow_call: # to make the workflow triggerable from other workflows (publish.yaml) + workflow_dispatch: # to make the workflow triggerable manually + +jobs: + update_files: + name: Update schema.json, examples, and entry figures + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Set up Python 3.12 + uses: actions/setup-python@v5 + with: + python-version: "3.12" + + - name: Install Hatch + uses: pypa/hatch@install + + - name: Set Git credentials + run: | + git config --global user.name "${{ github.actor }}" + git config --global user.email "${{ github.actor }}@users.noreply.github.com" + + - name: Update schema.json + run: | + hatch run docs:update-schema + git add schema.json + git commit -m "docs: update schema.json" + + - name: Update `examples` folder + run: | + hatch run docs:update-examples + git add examples/* + git commit -m "docs: update examples" + + - name: Update entry figures + run: | + hatch run docs:update-entry-figures + git add docs/assets/**/*.png + git commit -m "docs: update entry figures" + + - name: Push changes + run: | + git push origin HEAD:main