From 14c3a03591eabcfbb8a84cb868fca76c3c95f03a Mon Sep 17 00:00:00 2001 From: Markus / Mark <46672778+marksverdhei@users.noreply.github.com> Date: Fri, 13 Jun 2025 07:50:32 +0000 Subject: [PATCH 1/5] replace repo owner --- .github/workflows/template-init.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/template-init.yml b/.github/workflows/template-init.yml index df2ebe9..7588e0c 100644 --- a/.github/workflows/template-init.yml +++ b/.github/workflows/template-init.yml @@ -27,6 +27,7 @@ jobs: echo "repo_slug=${{ github.event.repository.name }}" >> "$GITHUB_OUTPUT" snake=$(echo "${{ github.event.repository.name }}" | tr '-' '_') echo "repo_snake=$snake" >> "$GITHUB_OUTPUT" + echo "repo_owner=${{ github.event.repository.owner.login }}" >> "$GITHUB_OUTPUT" - name: Create working branch run: git switch -c template-init @@ -35,11 +36,14 @@ jobs: run: | repo_slug="${{ steps.names.outputs.repo_slug }}" repo_snake="${{ steps.names.outputs.repo_snake }}" + repo_owner="${{ steps.names.outputs.repo_owner }}" # replace dash-style placeholder grep -lr --exclude-dir=.git 'python-template' . | xargs -r sed -i "s/python-template/${repo_slug}/g" # replace snake_case placeholder grep -lr --exclude-dir=.git 'python_template' . | xargs -r sed -i "s/python_template/${repo_snake}/g" + # replace repo owner placeholder + grep -lr --exclude-dir=.git 'marksverdhei' . | xargs -r sed -i "s/marksverdhei/${repo_owner}/g" - name: Rename files and directories run: | From 745bcd1230b3fd197dee78292a5e78b4eda60912 Mon Sep 17 00:00:00 2001 From: marksverdhei Date: Fri, 13 Jun 2025 11:53:02 +0200 Subject: [PATCH 2/5] Test run --- .github/workflows/template-init.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/template-init.yml b/.github/workflows/template-init.yml index 7588e0c..a3ffbb8 100644 --- a/.github/workflows/template-init.yml +++ b/.github/workflows/template-init.yml @@ -5,11 +5,12 @@ name: Template initialisation on: push: branches: - - main # runs after the very first push that creates the repo + - main # runs after the very first push that creates the repository + - replace-repo-owner jobs: init: # Do not run in the original template repository itself - if: github.event.repository.name != 'python-template' + # if: github.event.repository.name != 'python-template' runs-on: ubuntu-latest permissions: contents: write @@ -33,6 +34,7 @@ jobs: run: git switch -c template-init - name: Replace placeholders inside files + continue-on-error: true run: | repo_slug="${{ steps.names.outputs.repo_slug }}" repo_snake="${{ steps.names.outputs.repo_snake }}" @@ -44,8 +46,9 @@ jobs: grep -lr --exclude-dir=.git 'python_template' . | xargs -r sed -i "s/python_template/${repo_snake}/g" # replace repo owner placeholder grep -lr --exclude-dir=.git 'marksverdhei' . | xargs -r sed -i "s/marksverdhei/${repo_owner}/g" - + - name: Rename files and directories + continue-on-error: true run: | repo_slug="${{ steps.names.outputs.repo_slug }}" repo_snake="${{ steps.names.outputs.repo_snake }}" From 00e73921dcd802b0463adebc0baf962c5d7f458a Mon Sep 17 00:00:00 2001 From: marksverdhei Date: Fri, 13 Jun 2025 11:54:09 +0200 Subject: [PATCH 3/5] Add different repo owner name --- .github/workflows/template-init.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/template-init.yml b/.github/workflows/template-init.yml index a3ffbb8..88733f7 100644 --- a/.github/workflows/template-init.yml +++ b/.github/workflows/template-init.yml @@ -45,7 +45,7 @@ jobs: # replace snake_case placeholder grep -lr --exclude-dir=.git 'python_template' . | xargs -r sed -i "s/python_template/${repo_snake}/g" # replace repo owner placeholder - grep -lr --exclude-dir=.git 'marksverdhei' . | xargs -r sed -i "s/marksverdhei/${repo_owner}/g" + grep -lr --exclude-dir=.git 'marksverdhei' . | xargs -r sed -i "s/marksverdhei/${repo_owner}123/g" - name: Rename files and directories continue-on-error: true From 4303ca93b4100a4e870328bd014b3ec7d7026631 Mon Sep 17 00:00:00 2001 From: marksverdhei Date: Fri, 13 Jun 2025 11:57:55 +0200 Subject: [PATCH 4/5] Revert commits for testing --- .github/workflows/template-init.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/template-init.yml b/.github/workflows/template-init.yml index 88733f7..7588e0c 100644 --- a/.github/workflows/template-init.yml +++ b/.github/workflows/template-init.yml @@ -5,12 +5,11 @@ name: Template initialisation on: push: branches: - - main # runs after the very first push that creates the repository - - replace-repo-owner + - main # runs after the very first push that creates the repo jobs: init: # Do not run in the original template repository itself - # if: github.event.repository.name != 'python-template' + if: github.event.repository.name != 'python-template' runs-on: ubuntu-latest permissions: contents: write @@ -34,7 +33,6 @@ jobs: run: git switch -c template-init - name: Replace placeholders inside files - continue-on-error: true run: | repo_slug="${{ steps.names.outputs.repo_slug }}" repo_snake="${{ steps.names.outputs.repo_snake }}" @@ -45,10 +43,9 @@ jobs: # replace snake_case placeholder grep -lr --exclude-dir=.git 'python_template' . | xargs -r sed -i "s/python_template/${repo_snake}/g" # replace repo owner placeholder - grep -lr --exclude-dir=.git 'marksverdhei' . | xargs -r sed -i "s/marksverdhei/${repo_owner}123/g" - + grep -lr --exclude-dir=.git 'marksverdhei' . | xargs -r sed -i "s/marksverdhei/${repo_owner}/g" + - name: Rename files and directories - continue-on-error: true run: | repo_slug="${{ steps.names.outputs.repo_slug }}" repo_snake="${{ steps.names.outputs.repo_snake }}" From d0a2394d93cda5b16ac7638d2b037a40c625395e Mon Sep 17 00:00:00 2001 From: marksverdhei Date: Fri, 13 Jun 2025 12:01:58 +0200 Subject: [PATCH 5/5] Isolate owner step and run if owner is not me --- .github/workflows/template-init.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/template-init.yml b/.github/workflows/template-init.yml index 7588e0c..18cb7c9 100644 --- a/.github/workflows/template-init.yml +++ b/.github/workflows/template-init.yml @@ -32,18 +32,22 @@ jobs: - name: Create working branch run: git switch -c template-init + - name: Replace repo owner + if: ${{ github.event.repository.owner.login }} != marksverdhei + run: | + repo_owner="${{ steps.names.outputs.repo_owner }}" + # replace repo owner placeholder + grep -lr --exclude-dir=.git 'marksverdhei' . | xargs -r sed -i "s/marksverdhei/${repo_owner}/g" + - name: Replace placeholders inside files run: | repo_slug="${{ steps.names.outputs.repo_slug }}" repo_snake="${{ steps.names.outputs.repo_snake }}" - repo_owner="${{ steps.names.outputs.repo_owner }}" # replace dash-style placeholder grep -lr --exclude-dir=.git 'python-template' . | xargs -r sed -i "s/python-template/${repo_slug}/g" # replace snake_case placeholder grep -lr --exclude-dir=.git 'python_template' . | xargs -r sed -i "s/python_template/${repo_snake}/g" - # replace repo owner placeholder - grep -lr --exclude-dir=.git 'marksverdhei' . | xargs -r sed -i "s/marksverdhei/${repo_owner}/g" - name: Rename files and directories run: |