From 9e78ce59ce58b1a8120af5fc3c471cb35eaf3e32 Mon Sep 17 00:00:00 2001 From: Javid Ahmed Date: Fri, 6 Mar 2026 00:57:12 +0000 Subject: [PATCH 1/3] Add action to set PACKAGE_NAME environment variable in workflows --- .github/actions/setup/set-package-name/action.yml | 11 +++++++++++ .github/workflows/build.yml | 11 ++++++++--- .github/workflows/ci.yml | 7 ++++--- 3 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 .github/actions/setup/set-package-name/action.yml diff --git a/.github/actions/setup/set-package-name/action.yml b/.github/actions/setup/set-package-name/action.yml new file mode 100644 index 0000000..2341112 --- /dev/null +++ b/.github/actions/setup/set-package-name/action.yml @@ -0,0 +1,11 @@ +name: Set Package Name +description: Sets the PACKAGE_NAME environment variable by replacing hyphens with underscores in the repository name. + +runs: + using: composite + steps: + - name: Set package name + run: | + REPO_NAME="${{ github.event.repository.name }}" + echo "PACKAGE_NAME=${REPO_NAME//-/_}" >> $GITHUB_ENV + shell: bash diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ab27475..b678f87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -8,14 +8,15 @@ on: branches: - main -env: - PACKAGE_NAME: template_python - jobs: build-wheel: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: ./.github/actions/setup/set-package-name + if: ${{ github.repository == 'javidahmed64592/template-python' }} + # - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main + # if: ${{ github.repository != 'javidahmed64592/template-python' }} - uses: ./.github/actions/build/build-wheel if: ${{ github.repository == 'javidahmed64592/template-python' }} - uses: javidahmed64592/template-python/.github/actions/build/build-wheel@main @@ -26,6 +27,10 @@ jobs: needs: build-wheel steps: - uses: actions/checkout@v6 + - uses: ./.github/actions/setup/set-package-name + if: ${{ github.repository == 'javidahmed64592/template-python' }} + # - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main + # if: ${{ github.repository != 'javidahmed64592/template-python' }} - uses: ./.github/actions/build/verify-structure if: ${{ github.repository == 'javidahmed64592/template-python' }} - uses: javidahmed64592/template-python/.github/actions/build/verify-structure@main diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b6dd49a..18aea4c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -8,9 +8,6 @@ on: branches: - main -env: - PACKAGE_NAME: template_python - jobs: validate-pyproject: runs-on: ubuntu-latest @@ -52,6 +49,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 + - uses: ./.github/actions/setup/set-package-name + if: ${{ github.repository == 'javidahmed64592/template-python' }} + # - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main + # if: ${{ github.repository != 'javidahmed64592/template-python' }} - uses: ./.github/actions/ci/bandit if: ${{ github.repository == 'javidahmed64592/template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/bandit@main From 0c3ba213f3c80b391d4b7fbf2b2653c3549f42aa Mon Sep 17 00:00:00 2001 From: Javid Ahmed Date: Fri, 6 Mar 2026 00:58:40 +0000 Subject: [PATCH 2/3] Add action to set PACKAGE_NAME environment variable in workflows --- docs/WORKFLOWS.md | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/docs/WORKFLOWS.md b/docs/WORKFLOWS.md index 0de05ba..951522f 100644 --- a/docs/WORKFLOWS.md +++ b/docs/WORKFLOWS.md @@ -65,6 +65,21 @@ steps: --- +**set-package-name:** +- Description: Sets the `PACKAGE_NAME` environment variable by replacing hyphens with underscores in the repository name. +- Location: `set-package-name/action.yml` +- Steps: + - Derives `PACKAGE_NAME` from `github.event.repository.name` using bash parameter expansion (`${REPO_NAME//-/_}`) + - Writes the result to `$GITHUB_ENV` so it is available to all subsequent steps + +Usage: +```yaml +steps: + - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main +``` + +--- + ### CI Actions (`/ci/**/action.yml`) **validate-pyproject:** @@ -139,9 +154,8 @@ steps: Usage: ```yaml -env: - PACKAGE_NAME: your_package_name steps: + - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - uses: javidahmed64592/template-python/.github/actions/ci/bandit@main ``` @@ -201,9 +215,8 @@ steps: Usage: ```yaml -env: - PACKAGE_NAME: your_package_name steps: + - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - uses: javidahmed64592/template-python/.github/actions/build/build-wheel@main ``` @@ -221,9 +234,8 @@ steps: Usage: ```yaml -env: - PACKAGE_NAME: your_package_name steps: + - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - uses: javidahmed64592/template-python/.github/actions/build/verify-structure@main ``` From 13a852f261683d48e8a1e65c1ced1372621db376 Mon Sep 17 00:00:00 2001 From: Javid Ahmed Date: Fri, 6 Mar 2026 01:00:39 +0000 Subject: [PATCH 3/3] Refactor repository checks to use github.event.repository.name for consistency across workflows and actions --- .github/actions/build/build-wheel/action.yml | 4 +-- .../actions/build/verify-structure/action.yml | 4 +-- .github/actions/ci/bandit/action.yml | 4 +-- .github/actions/ci/mypy/action.yml | 4 +-- .github/actions/ci/pip-audit/action.yml | 4 +-- .github/actions/ci/pytest/action.yml | 4 +-- .github/actions/ci/ruff/action.yml | 4 +-- .../actions/ci/validate-pyproject/action.yml | 4 +-- .github/actions/ci/version-check/action.yml | 4 +-- .../setup/install-python-core/action.yml | 4 +-- .../setup/install-python-dev/action.yml | 4 +-- .github/workflows/build.yml | 16 +++++----- .github/workflows/ci.yml | 32 +++++++++---------- 13 files changed, 46 insertions(+), 46 deletions(-) diff --git a/.github/actions/build/build-wheel/action.yml b/.github/actions/build/build-wheel/action.yml index 9b4c936..7854994 100644 --- a/.github/actions/build/build-wheel/action.yml +++ b/.github/actions/build/build-wheel/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-core - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-core@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Create wheel run: | diff --git a/.github/actions/build/verify-structure/action.yml b/.github/actions/build/verify-structure/action.yml index edee5a7..142df6f 100644 --- a/.github/actions/build/verify-structure/action.yml +++ b/.github/actions/build/verify-structure/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-core - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-core@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Download wheel artifact uses: actions/download-artifact@v7 diff --git a/.github/actions/ci/bandit/action.yml b/.github/actions/ci/bandit/action.yml index 6e00aed..6bbb76a 100644 --- a/.github/actions/ci/bandit/action.yml +++ b/.github/actions/ci/bandit/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Security check run: | diff --git a/.github/actions/ci/mypy/action.yml b/.github/actions/ci/mypy/action.yml index c2cf6b2..18b3162 100644 --- a/.github/actions/ci/mypy/action.yml +++ b/.github/actions/ci/mypy/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Check with mypy run: | diff --git a/.github/actions/ci/pip-audit/action.yml b/.github/actions/ci/pip-audit/action.yml index e682b18..0844e10 100644 --- a/.github/actions/ci/pip-audit/action.yml +++ b/.github/actions/ci/pip-audit/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Audit dependencies run: | diff --git a/.github/actions/ci/pytest/action.yml b/.github/actions/ci/pytest/action.yml index 6f5dff8..4add27b 100644 --- a/.github/actions/ci/pytest/action.yml +++ b/.github/actions/ci/pytest/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Test with pytest run: | diff --git a/.github/actions/ci/ruff/action.yml b/.github/actions/ci/ruff/action.yml index 321f384..d44e7fc 100644 --- a/.github/actions/ci/ruff/action.yml +++ b/.github/actions/ci/ruff/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Check with ruff run: | diff --git a/.github/actions/ci/validate-pyproject/action.yml b/.github/actions/ci/validate-pyproject/action.yml index aa79d89..214bc7f 100644 --- a/.github/actions/ci/validate-pyproject/action.yml +++ b/.github/actions/ci/validate-pyproject/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Validate pyproject.toml run: | diff --git a/.github/actions/ci/version-check/action.yml b/.github/actions/ci/version-check/action.yml index b4ea0be..fc7f170 100644 --- a/.github/actions/ci/version-check/action.yml +++ b/.github/actions/ci/version-check/action.yml @@ -12,9 +12,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/install-python-dev - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/install-python-dev@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Check version consistency run: | diff --git a/.github/actions/setup/install-python-core/action.yml b/.github/actions/setup/install-python-core/action.yml index fde5028..5bf9797 100644 --- a/.github/actions/setup/install-python-core/action.yml +++ b/.github/actions/setup/install-python-core/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/setup-uv-python - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/setup-uv-python@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Install dependencies run: | diff --git a/.github/actions/setup/install-python-dev/action.yml b/.github/actions/setup/install-python-dev/action.yml index a627331..be96318 100644 --- a/.github/actions/setup/install-python-dev/action.yml +++ b/.github/actions/setup/install-python-dev/action.yml @@ -6,9 +6,9 @@ runs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/setup-uv-python - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/setup/setup-uv-python@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} - name: Install dependencies run: | diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index b678f87..b68ccba 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -14,13 +14,13 @@ jobs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/set-package-name - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} # - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - # if: ${{ github.repository != 'javidahmed64592/template-python' }} + # if: ${{ github.event.repository.name != 'template-python' }} - uses: ./.github/actions/build/build-wheel - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/build/build-wheel@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} verify-structure: runs-on: ubuntu-latest @@ -28,10 +28,10 @@ jobs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/set-package-name - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} # - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - # if: ${{ github.repository != 'javidahmed64592/template-python' }} + # if: ${{ github.event.repository.name != 'template-python' }} - uses: ./.github/actions/build/verify-structure - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/build/verify-structure@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18aea4c..6b4e32e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,64 +14,64 @@ jobs: steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/validate-pyproject - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/validate-pyproject@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} ruff: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/ruff - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/ruff@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} mypy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/mypy - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/mypy@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} pytest: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/pytest - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/pytest@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} bandit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/setup/set-package-name - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} # - uses: javidahmed64592/template-python/.github/actions/setup/set-package-name@main - # if: ${{ github.repository != 'javidahmed64592/template-python' }} + # if: ${{ github.event.repository.name != 'template-python' }} - uses: ./.github/actions/ci/bandit - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/bandit@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} pip-audit: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/pip-audit - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/pip-audit@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }} version-check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 - uses: ./.github/actions/ci/version-check - if: ${{ github.repository == 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name == 'template-python' }} - uses: javidahmed64592/template-python/.github/actions/ci/version-check@main - if: ${{ github.repository != 'javidahmed64592/template-python' }} + if: ${{ github.event.repository.name != 'template-python' }}