workflows: create update-files.yaml workflow

This commit is contained in:
Sina Atalay
2024-07-16 14:14:30 +03:00
parent f28b04f041
commit 755ad0bf15
3 changed files with 62 additions and 51 deletions

View File

@@ -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

View File

@@ -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

54
.github/workflows/update-files.yaml vendored Normal file
View File

@@ -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