chore: add GitHub Actions workflow for publishing Node image - #1166
Conversation
This commit introduces a new workflow in `.github/workflows/publish-node-image.yaml` to automate the building and pushing of a Docker image to the GitHub Container Registry upon release events. Additionally, it updates the `Dockerfile` to use environment variables for configuration and refines the entrypoint script to improve clarity and maintainability.
WalkthroughAdds a GitHub Actions workflow to build and publish a Docker image to GHCR on release or manual trigger. Updates Docker build configuration and entrypoint: renames/introduces setup environment variables, sets Changes
Sequence Diagram(s)sequenceDiagram
autonumber
actor Dev as Developer
participant GH as GitHub
participant GHA as GitHub Actions
participant Buildx as Docker Buildx
participant GHCR as GitHub Container Registry
Dev->>GH: create release or trigger workflow_dispatch
GH->>GHA: start "Publish Node Image"
GHA->>GHA: set IMAGE_NAME, compute TAG_LATEST
GHA->>GHA: docker/metadata-action -> produce tags/labels
GHA->>Buildx: build multi-arch image from deployments/Dockerfile
GHA->>GHCR: push image with generated tags
GHA-->>Dev: publish summary (image, ref, tags)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing touches🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This commit adds an input option to the workflow for tagging builds as 'latest' during manual dispatch. It also introduces an environment variable to control the tagging logic based on the event type, improving the flexibility of the image publishing process.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
deployments/Dockerfile (1)
45-56: BUG: CONFIG_PATH is expanded at build-time, breaking runtime overrides.In these echo lines, $CONFIG_PATH is expanded while building the image, hard-coding /root/.kwild into /app/config.sh. Users cannot override CONFIG_PATH at runtime. Also, cp with a glob misses dotfiles and can fail when the directory is empty.
Apply runtime-safe escaping and robust copy:
- echo "set -xe" >> /app/config.sh && \ - echo "if [ ! -f $CONFIG_PATH/config.toml ]; then" >> /app/config.sh && \ + echo "set -xe" >> /app/config.sh && \ + echo "if [ ! -f \"\$CONFIG_PATH/config.toml\" ]; then" >> /app/config.sh && \ echo " echo 'Configuration does not exist';" >> /app/config.sh && \ echo " echo 'Creating configuration';" >> /app/config.sh && \ echo " ./kwild setup init --chain-id \"\$SETUP_CHAIN_ID\" --db-owner \"\$SETUP_DB_OWNER\" -r '/root/.kwil-new';" >> /app/config.sh && \ - echo " mkdir -p $CONFIG_PATH;" >> /app/config.sh && \ - echo " cp /root/.kwil-new/* $CONFIG_PATH;" >> /app/config.sh && \ + echo " mkdir -p \"\$CONFIG_PATH\";" >> /app/config.sh && \ + echo " cp -a /root/.kwil-new/. \"\$CONFIG_PATH/\";" >> /app/config.sh && \ echo " rm -rf /root/.kwil-new;" >> /app/config.sh && \ echo " echo 'Configuration created';" >> /app/config.sh && \ echo "else" >> /app/config.sh && \ echo " echo 'Configuration already exists';" >> /app/config.sh && \ echo "fi" >> /app/config.sh
🧹 Nitpick comments (6)
deployments/tn-entrypoint.sh (1)
17-17: Quote CONFIG_PATH in exec to avoid word splitting; verify removed flags’ defaults.Use quotes for safety. Also confirm kwild’s defaults for the removed options are acceptable in prod.
-exec /app/kwild start --root $CONFIG_PATH +exec /app/kwild start --root "$CONFIG_PATH"deployments/Dockerfile (2)
45-56: Make db-owner optional to avoid passing an empty value to kwild.If SETUP_DB_OWNER is unset, kwild may reject --db-owner "". Gate the flag conditionally in the script.
Proposed inline script logic:
- echo " ./kwild setup init --chain-id \"\$SETUP_CHAIN_ID\" --db-owner \"\$SETUP_DB_OWNER\" -r '/root/.kwil-new';" >> /app/config.sh && \ + echo " OWNER_FLAG=\"\"; [ -n \"\$SETUP_DB_OWNER\" ] && OWNER_FLAG=\"--db-owner \\\"\$SETUP_DB_OWNER\\\"\";" >> /app/config.sh && \ + echo " ./kwild setup init --chain-id \"\$SETUP_CHAIN_ID\" \$OWNER_FLAG -r '/root/.kwil-new';" >> /app/config.sh && \
43-56: Prefer a heredoc over chained echos for maintainability and correct quoting.This avoids accidental expansions and is easier to diff.
-RUN echo "#!/bin/sh" > /app/config.sh && \ - echo "set -xe" >> /app/config.sh && \ - echo "if [ ! -f \"\$CONFIG_PATH/config.toml\" ]; then" >> /app/config.sh && \ - echo " echo 'Configuration does not exist';" >> /app/config.sh && \ - echo " echo 'Creating configuration';" >> /app/config.sh && \ - echo " OWNER_FLAG=\"\"; [ -n \"\$SETUP_DB_OWNER\" ] && OWNER_FLAG=\"--db-owner \\\"\$SETUP_DB_OWNER\\\"\";" >> /app/config.sh && \ - echo " ./kwild setup init --chain-id \"\$SETUP_CHAIN_ID\" \$OWNER_FLAG -r '/root/.kwil-new';" >> /app/config.sh && \ - echo " mkdir -p \"\$CONFIG_PATH\";" >> /app/config.sh && \ - echo " cp -a /root/.kwil-new/. \"\$CONFIG_PATH/\";" >> /app/config.sh && \ - echo " rm -rf /root/.kwil-new;" >> /app/config.sh && \ - echo " echo 'Configuration created';" >> /app/config.sh && \ - echo "else" >> /app/config.sh && \ - echo " echo 'Configuration already exists';" >> /app/config.sh && \ - echo "fi" >> /app/config.sh +RUN cat > /app/config.sh <<'EOF' +#!/bin/sh +set -xe +if [ ! -f "$CONFIG_PATH/config.toml" ]; then + echo 'Configuration does not exist' + echo 'Creating configuration' + OWNER_FLAG="" + if [ -n "$SETUP_DB_OWNER" ]; then OWNER_FLAG="--db-owner $SETUP_DB_OWNER"; fi + ./kwild setup init --chain-id "$SETUP_CHAIN_ID" $OWNER_FLAG -r '/root/.kwil-new' + mkdir -p "$CONFIG_PATH" + cp -a /root/.kwil-new/. "$CONFIG_PATH/" + rm -rf /root/.kwil-new + echo 'Configuration created' +else + echo 'Configuration already exists' +fi +EOF.github/workflows/publish-node-image.yaml (3)
62-66: Use printf for newlines; echo won’t expand \n reliably.Actionlint SC2028 is valid here; switch to printf.
- - name: Summary - run: | - echo "Image pushed: ${{ env.IMAGE_NAME }}" - echo "Ref: ${{ github.ref }}" - echo "Tags:\n${{ steps.meta.outputs.tags }}" + - name: Summary + run: | + printf 'Image pushed: %s\n' '${{ env.IMAGE_NAME }}' + printf 'Ref: %s\n' '${{ github.ref }}' + printf 'Tags:\n%s\n' '${{ steps.meta.outputs.tags }}'
52-61: Enable build cache to speed repeated builds.GHA cache with Buildx is low-risk and improves CI latency.
- name: Build and push image uses: docker/build-push-action@v5 with: context: . file: deployments/Dockerfile push: true platforms: linux/amd64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max
14-17: Add concurrency to prevent overlapping publishes from racing tags.Avoids concurrent runs pushing different images under the same tag.
permissions: contents: read packages: write +concurrency: + group: publish-node-image-${{ github.ref }} + cancel-in-progress: false
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
.github/workflows/publish-node-image.yaml(1 hunks)deployments/Dockerfile(2 hunks)deployments/tn-entrypoint.sh(1 hunks)
🧰 Additional context used
🪛 actionlint (1.7.7)
.github/workflows/publish-node-image.yaml
63-63: shellcheck reported issue in this script: SC2028:info:3:6: echo may not expand escape sequences. Use printf
(shellcheck)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: acceptance-test
Time Submission Status
|
…ilds This commit modifies the Node image publishing workflow to enable building and pushing Docker images for both amd64 and arm64 architectures. This enhancement improves compatibility and accessibility of the published images across different platforms.
Description
This commit introduces a new workflow in
.github/workflows/publish-node-image.yamlto automate the building and pushing of a Docker image to the GitHub Container Registry upon release events. Additionally, it updates theDockerfileto use environment variables for configuration and refines the entrypoint script to improve clarity and maintainability.Related Problem
How Has This Been Tested?
Summary by CodeRabbit
New Features
Changes
Chores