Skip to content

Commit 40f3b6a

Browse files
committed
automatically filled repository link and separation from homepage_url
1 parent f90d30b commit 40f3b6a

2 files changed

Lines changed: 17 additions & 7 deletions

File tree

.github/workflows/configure_project.yml

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ on:
1111
description: 'A short description of the project.'
1212
required: true
1313
default: 'A new awesome project.'
14-
project_homepage_url:
15-
description: "The URL for the project's GitHub homepage."
16-
required: true
17-
default: 'https://github.com/username/repo'
1814
cpack_package_contact:
1915
description: 'The contact email for the project.'
2016
required: true
2117
default: 'user@example.com'
18+
project_homepage_url:
19+
description: "The URL for the project's homepage. Leave empty to use the repository URL."
20+
required: false
21+
default: 'Leave empty to use repository URL'
2222

2323
jobs:
2424
configure_project:
@@ -42,6 +42,15 @@ jobs:
4242
PROJECT_NAME_LOWER=$(echo "${{ github.event.inputs.new_project_name }}" | tr '[:upper:]' '[:lower:]' | tr ' ' '_')
4343
echo "project_name_lower=$PROJECT_NAME_LOWER" >> $GITHUB_OUTPUT
4444
45+
- name: Set homepage URL
46+
id: set-url
47+
run: |
48+
if [ "${{ github.event.inputs.project_homepage_url }}" = "Leave empty to use repository URL" ] || [ -z "${{ github.event.inputs.project_homepage_url }}" ]; then
49+
echo "homepage_url=${{ github.server_url }}/${{ github.repository }}" >> $GITHUB_OUTPUT
50+
else
51+
echo "homepage_url=${{ github.event.inputs.project_homepage_url }}" >> $GITHUB_OUTPUT
52+
fi
53+
4554
- name: Replace project template placeholders
4655
run: |
4756
# This command finds all files and uses 'sed' to replace all the placeholders.
@@ -50,7 +59,8 @@ jobs:
5059
-e "s|{{PROJECT_NAME}}|${{ github.event.inputs.new_project_name }}|g" \
5160
-e "s|{{PROJECT_NAME_LOWER}}|${{ steps.set-variables.outputs.project_name_lower }}|g" \
5261
-e "s|{{PROJECT_DESCRIPTION}}|${{ github.event.inputs.project_description }}|g" \
53-
-e "s|{{PROJECT_HOMEPAGE_URL}}|${{ github.event.inputs.project_homepage_url }}|g" \
62+
-e "s|{{PROJECT_REPOSITORY_URL}}|${{ github.server_url }}/${{ github.repository }}|g" \
63+
-e "s|{{PROJECT_HOMEPAGE_URL}}|${{ steps.set-url.outputs.homepage_url }}|g" \
5464
-e "s|{{CPACK_PACKAGE_CONTACT}}|${{ github.event.inputs.cpack_package_contact }}|g" \
5565
{} +
5666
@@ -72,4 +82,4 @@ jobs:
7282
body: |
7383
This pull request configures the project from the template with the information you provided.
7484
branch: configure-project-${{ github.run_number }}
75-
token: ${{ secrets.GITHUB_TOKEN }}
85+
token: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# {{PROJECT_NAME}}
2-
[![.github/workflows/ci-cd.yml]({{PROJECT_HOMEPAGE_URL}}/actions/workflows/ci-cd.yml/badge.svg)]({{PROJECT_HOMEPAGE_URL}}/actions/workflows/ci-cd.yml)
2+
[![.github/workflows/ci-cd.yml]({{PROJECT_REPOSITORY_URL}}/actions/workflows/ci-cd.yml/badge.svg)]({{PROJECT_REPOSITORY_URL}}/actions/workflows/ci-cd.yml)
33

44
Repository template for a cross-platform project written in C++ with use of Conan and CMake. This template has also GitHub actions configured for CI/CD with static analysis by clang-tidy and cppcheck. It has also clang-format configuration file for code formatting.
55

0 commit comments

Comments
 (0)