Skip to content
This repository was archived by the owner on Apr 19, 2023. It is now read-only.

Commit c77d33f

Browse files
authored
Merge pull request #32 from LtdSauce/main
Janitor: Add safe project name for cpp/hpp files
2 parents f37c1ab + a919c66 commit c77d33f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

.github/workflows/template-janitor.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,11 +61,23 @@ jobs:
6161
env:
6262
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6363

64+
- name: Use testing variables if still a template
65+
if: fromJson(steps.get_repo_meta.outputs.data).is_template == true
66+
run: |
67+
# This name is unsafe because it is not a valid C++ identifier
68+
echo "NEW_PROJECT=my-unsafe.project" >> $GITHUB_ENV
69+
70+
- name: Add safe replacement variable versions
71+
run: |
72+
# hyphens and dots in c++ identifiers are forbidden. Use underscores instead.
73+
NEW_SAFE_PROJECT=$(echo ${{ env.NEW_PROJECT }} | sed "s/-/_/g" | sed "s/\./_/g" )
74+
echo "NEW_SAFE_PROJECT=$NEW_SAFE_PROJECT" >> $GITHUB_ENV
75+
6476
# Rename all cpp_starter_project occurences to current repository and remove this workflow
6577
- name: Insert new org and project
6678
run: |
6779
# rename the CMake project to match the github project
68-
sed -i "s/myproject/${{ github.event.repository.name }}/gi" CMakeLists.txt configured_files/config.hpp.in src/main.cpp
80+
sed -i "s/myproject/${{ env.NEW_SAFE_PROJECT }}/gi" CMakeLists.txt configured_files/config.hpp.in src/main.cpp
6981
7082
# Update URL placeholders for project
7183
sed -i "s|%%myurl%%|${{ fromJson(steps.get_repo_meta.outputs.data).html_url }}|gi" CMakeLists.txt
@@ -120,7 +132,8 @@ jobs:
120132
- name: Test simple configuration to make sure nothing broke
121133
run: |
122134
cmake -S . -B ./build -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE:STRING=${{ matrix.build_type }} -DENABLE_DEVELOPER_MODE:BOOL=${{ matrix.developer_mode }} -DOPT_ENABLE_COVERAGE:BOOL=OFF
123-
135+
# Build it because we may have broken something in the cpp/hpp files
136+
cmake --build build
124137
125138
- uses: EndBug/add-and-commit@v4
126139
# only commit and push if we are not a template project anymore!

0 commit comments

Comments
 (0)