-
Notifications
You must be signed in to change notification settings - Fork 584
ci: fix Docker tag format and add version pinning for transport builds #132
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -145,18 +145,22 @@ jobs: | |
|
|
||
| echo "tag=${TAG}" >> $GITHUB_OUTPUT | ||
|
|
||
| # Extract version from tag | ||
| VERSION=${TAG#transports/v} | ||
| # Extract version from tag (remove transports/ prefix) | ||
| VERSION=${TAG#transports/} | ||
| echo "version=${VERSION}" >> $GITHUB_OUTPUT | ||
|
|
||
| # Extract numeric version for validation | ||
| NUMERIC_VERSION=${VERSION#v} | ||
|
|
||
| # Validate version format | ||
| if ! echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then | ||
| if ! echo "$NUMERIC_VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+$'; then | ||
| echo "Error: Invalid tag format '$TAG'. Expected format: transports/vMAJOR.MINOR.PATCH" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Create image tags (Docker tags cannot contain slashes, so use version only) | ||
| echo "tags<<EOF" >> $GITHUB_OUTPUT | ||
| echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:v${VERSION}" >> $GITHUB_OUTPUT | ||
| echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:${VERSION}" >> $GITHUB_OUTPUT | ||
| echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:latest" >> $GITHUB_OUTPUT | ||
| echo "EOF" >> $GITHUB_OUTPUT | ||
|
Comment on lines
162
to
165
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Use the official multi-line Manually echoing the {
echo 'tags<<EOF'
echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:${VERSION}"
echo "${{ env.REGISTRY }}/${{ env.ACCOUNT }}/${{ env.IMAGE_NAME }}:latest"
echo 'EOF'
} >>"$GITHUB_OUTPUT"Wrapping the block in braces guarantees the heredoc is kept together and reduces chances of accidental redirection mistakes during future edits. 🤖 Prompt for AI Agents |
||
|
|
||
|
|
@@ -192,6 +196,7 @@ jobs: | |
| org.opencontainers.image.revision=${{ github.sha }} | ||
| build-args: | | ||
| TRANSPORT_TYPE=http | ||
| TAG_VERSION=${{ steps.meta.outputs.version }} | ||
|
Comment on lines
198
to
+199
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Minor: keep build-arg list transport-agnostic
Consider: build-args: |
TRANSPORT_TYPE=${{ env.TRANSPORT_TYPE }}
TAG_VERSION=${{ steps.meta.outputs.version }}and source 🤖 Prompt for AI Agents |
||
| platforms: linux/amd64,linux/arm64 | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -8,12 +8,13 @@ RUN apk add --no-cache upx | |||||||||||||||||||||||||||||
| # Set environment for static build | ||||||||||||||||||||||||||||||
| ENV CGO_ENABLED=0 GOOS=linux GOARCH=amd64 | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Define build-time variable for transport type | ||||||||||||||||||||||||||||||
| # Define build-time variables | ||||||||||||||||||||||||||||||
| ARG TRANSPORT_TYPE=http | ||||||||||||||||||||||||||||||
| ARG TAG_VERSION=latest | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Initialize go module and get bifrost-http | ||||||||||||||||||||||||||||||
| # Initialize go module and get bifrost with specified tag | ||||||||||||||||||||||||||||||
| RUN go mod init bifrost-build && \ | ||||||||||||||||||||||||||||||
| go get github.com/maximhq/bifrost/transports/bifrost-${TRANSPORT_TYPE}@latest | ||||||||||||||||||||||||||||||
| go get github.com/maximhq/bifrost/transports/bifrost-${TRANSPORT_TYPE}@${TAG_VERSION} | ||||||||||||||||||||||||||||||
|
Comment on lines
+13
to
+17
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧹 Nitpick (assertive) Consider switching from
-ARG TAG_VERSION=latest
-# Initialize go module and get bifrost with specified tag
-RUN go mod init bifrost-build && \
- go get github.com/maximhq/bifrost/transports/bifrost-${TRANSPORT_TYPE}@${TAG_VERSION}
+# Explicit module initialisation
+ARG TAG_VERSION=latest
+RUN go mod init bifrost-build && \
+ go mod tidy && \
+ go install github.com/maximhq/bifrost/transports/bifrost-${TRANSPORT_TYPE}@${TAG_VERSION} && \
+ go mod downloadThis keeps the Docker layer deterministic, avoids side-effects in 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| # Build the binary locally | ||||||||||||||||||||||||||||||
| RUN go build \ | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Path-traversal & whitespace hardening for extracted version
VERSION=${TAG#transports/}andNUMERIC_VERSION=${VERSION#v}rely on the incoming tag being perfectly formed.If a malicious (or simply mistyped) tag like
transports/v1.2.3$(printf '\nX')were pushed, the newline would bleed into subsequentecho >> $GITHUB_OUTPUTlines and break the workflow / poison the build args.Add simple sanitation:
or use
printf '%s\n'instead of bareechowhen writing to$GITHUB_OUTPUT.Tiny change – big safety net.
🤖 Prompt for AI Agents