Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

justfile: Sanitize branch names before using them in container tags #64

Merged
merged 1 commit into from
Nov 8, 2024

Conversation

qmonnet
Copy link
Member

@qmonnet qmonnet commented Nov 8, 2024

Using the branch name as part of containers tags fails when branch names contain characters that are not valid for container tags (or not valid at the location where we use the branch name in the tag string).

To prevent the CI workflow from failing when the Pull Request branch name contains a slash, for example, sanitize the branch name before using it.

We sanitize it by translating (tr) everything that is not (-c) an alphanumeric character ([:alnum:]) or a line break (\n) into dashes. We keep line breaks because we don't want the final line break appended by echo to be converted into a dash; assigning the string to _branch will trim the ending line break anyway.

Fixes: #21

Using the branch name as part of containers tags fails when branch names
contain characters that are not valid for container tags (or not valid
at the location where we use the branch name in the tag string).

To prevent the CI workflow from failing when the Pull Request branch
name contains a slash, for example, sanitize the branch name before
using it.

We sanitize it by translating ('tr') everything that is not ('-c') an
alphanumeric character ('[:alnum:]') or a line break ('\n') into dashes.
We keep line breaks because we don't want the final line break appended
by echo to be converted into a dash; assigning the string to '_branch'
will trim the ending line break anyway.

Fixes: b88ec42 ("Build system")
Signed-off-by: Quentin Monnet <[email protected]>
@qmonnet qmonnet added bug Something isn't working ci Continuous Integration labels Nov 8, 2024
@qmonnet qmonnet requested a review from daniel-noland November 8, 2024 22:58
@qmonnet
Copy link
Member Author

qmonnet commented Nov 8, 2024

CI check sterile.yml passed \o/

Copy link
Collaborator

@daniel-noland daniel-noland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice LGTM

@daniel-noland daniel-noland merged commit 778e1fb into main Nov 8, 2024
12 checks passed
@daniel-noland daniel-noland deleted the pr/qmonnet/branch-sanitise branch November 8, 2024 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ci Continuous Integration
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants