From acff90b066658074d1925418c2c285fb6a202243 Mon Sep 17 00:00:00 2001 From: Timo Behrendt Date: Thu, 26 Feb 2026 22:36:25 +0100 Subject: [PATCH] feat: add get-repo-name (#20) Reviewed-on: https://gitea.t000-n.de/t.behrendt/actions/pulls/20 Co-authored-by: Timo Behrendt Co-committed-by: Timo Behrendt --- .gitea/workflows/ci.yaml | 16 ++++++++++++++++ README.md | 3 ++- get-repo-name/README.md | 11 +++++++++++ get-repo-name/action.yaml | 16 ++++++++++++++++ 4 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 .gitea/workflows/ci.yaml create mode 100644 get-repo-name/README.md create mode 100644 get-repo-name/action.yaml diff --git a/.gitea/workflows/ci.yaml b/.gitea/workflows/ci.yaml new file mode 100644 index 0000000..271b6ad --- /dev/null +++ b/.gitea/workflows/ci.yaml @@ -0,0 +1,16 @@ +name: CI + +on: + pull_request: + +jobs: + test_get-repo-name: + name: Test get-repo-name + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - id: repo + uses: ./get-repo-name + - run: | + test "${{ steps.repo.outputs.name }}" = "actions" || (echo "Expected repo name 'actions', got '${{ steps.repo.outputs.name }}'" && exit 1) + - run: echo "Original repository name is ${{ GITEA_REPOSITORY }}" diff --git a/README.md b/README.md index 90ae4ad..6849623 100644 --- a/README.md +++ b/README.md @@ -4,5 +4,6 @@ Collection of Gitea friendly actions. ## Actions -- [release-git-tag](./release-git-tag//README.md) +- [get-repo-name](./get-repo-name/README.md) +- [release-git-tag](./release-git-tag/README.md) - [release-helm-chart](./release-helm-chart/README.md) diff --git a/get-repo-name/README.md b/get-repo-name/README.md new file mode 100644 index 0000000..8e63680 --- /dev/null +++ b/get-repo-name/README.md @@ -0,0 +1,11 @@ +# get-repo-name + +Outputs the repository name from the Git/Gitea/GitHub environment without the owner. + +Example: `t.behrendt/actions` → `actions` + +```yaml +- id: repo + uses: https://gitea.t000-n.de/t.behrendt/actions/get-repo-name@0.0.0 +- run: echo "Repository name is ${{ steps.repo.outputs.name }}" +``` diff --git a/get-repo-name/action.yaml b/get-repo-name/action.yaml new file mode 100644 index 0000000..1b832a7 --- /dev/null +++ b/get-repo-name/action.yaml @@ -0,0 +1,16 @@ +name: Get repo name +description: Outputs the repository name without the owner (e.g. "owner/repo" → "repo") + +outputs: + name: + description: The repository name without the owner + value: ${{ steps.repo-name.outputs.name }} + +runs: + using: "composite" + steps: + - id: repo-name + shell: bash + run: | + REPO="${GITEA_REPOSITORY:-$GITHUB_REPOSITORY}" + echo "name=${REPO##*/}" >> $GITHUB_OUTPUT