I am trying to prepare artifact name prefix using GitHub Actions that will replace project name special characters with hyphens. I have this piece of code:
strategy:
matrix:
project:
- Common/Helpers.Tests
- PlaywrightXunitParallel
- name: Set artifact prefix
id: artifact_prefix
run: |
PROJECT_NAME=${{ matrix.project }}
ARTIFACT_PREFIX=${PROJECT_NAME/[^A-Za-z0-9\-]/-}
echo "::set-output name=lowercase::${ARTIFACT_PREFIX,,}"
However, I realized that regex is performed only once and result for project Common/Helpers.Tests is common-helpers.tests instead of common-helpers-tests.
I have tried to mark it as global like this: ARTIFACT_PREFIX=${PROJECT_NAME/[^A-Za-z0-9\-]/-/g} but it is not working as expected.
How can I replace all occurrences of special characters from project name?
Link to repo: https://github.com/gucu112/CSharpAutomation/actions/runs/18258362933#artifacts
//to replace all occurrences, instead ofgat the end:ARTIFACT_PREFIX=${PROJECT_NAME//[^A-Za-z0-9-]/-}