Skip to content

Add GitHub Actions workflow to build and push OpenClaw image#5

Open
natifridman wants to merge 2 commits intoredhat-et:mainfrom
natifridman:build-action
Open

Add GitHub Actions workflow to build and push OpenClaw image#5
natifridman wants to merge 2 commits intoredhat-et:mainfrom
natifridman:build-action

Conversation

@natifridman
Copy link
Contributor

@natifridman natifridman commented Mar 5, 2026

Builds the container image nightly and on Dockerfile changes to main, pushing to quay.io/aicatalyst/openclaw. PRs with Dockerfile changes trigger build-only (no push).

Required GitHub repository secrets:
QUAY_USERNAME - Quay.io robot account or username
QUAY_PASSWORD - Quay.io robot account token or password

Summary by CodeRabbit

  • Chores

    • Added an automated pipeline to build and publish the application container image on a schedule, when the build definition changes, for pull requests, and via manual dispatch; images are tagged (latest, date, and release tag) and pushed to the container registry.
  • Impact

    • No direct end-user visible changes or feature updates.

@coderabbitai
Copy link

coderabbitai bot commented Mar 5, 2026

📝 Walkthrough

Walkthrough

Adds a new GitHub Actions workflow that builds and pushes a Docker image to quay.io. Triggers: nightly schedule, pushes when Dockerfile changes on main, pull requests touching the Dockerfile, and manual dispatch. Computes tags, sets up Buildx, conditionally logs into quay.io, and builds/pushes with cache.

Changes

Cohort / File(s) Summary
CI/CD Workflow
.github/workflows/build-image.yml
New workflow that computes image tags (latest, date, git-tag), sets up Docker Buildx, conditionally logs into quay.io (skips login for PR events), and builds & pushes the image using docker/build-push-action with cache support. Triggers: schedule, push on Dockerfile change, PRs, manual dispatch.

Sequence Diagram(s)

sequenceDiagram
    participant Repo as "Repository"
    participant GH as "GitHub Actions"
    participant Buildx as "Docker Buildx"
    participant Quay as "quay.io Registry"

    Repo->>GH: Trigger (schedule / push / PR / manual)
    GH->>GH: Checkout repo
    GH->>GH: Compute tags (latest, date, git-tag)
    GH->>Buildx: Set up Buildx builder
    alt event != pull_request
        GH->>Quay: Login with quay credentials
    end
    GH->>Buildx: Build image, apply tags, use cache
    Buildx->>Quay: Push image tags
    Quay-->>GH: Acknowledge push
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately and clearly summarizes the main change: adding a GitHub Actions workflow for building and pushing the OpenClaw Docker image.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🧹 Nitpick comments (1)
.github/workflows/build-image.yml (1)

18-20: Add explicit least-privilege workflow permissions.

No permissions block is defined; default token scope can be broader than needed.

Proposed fix
 jobs:
   build:
+    permissions:
+      contents: read
     runs-on: ubuntu-latest
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/build-image.yml around lines 18 - 20, The workflow is
missing an explicit least-privilege permissions block for the build job; add a
permissions entry scoped to only the GitHub token privileges required by this
job (attach a permissions map under the build job or at workflow root) and
restrict each scope (e.g., contents, packages, pull-requests, id-token, etc.) to
read or write only as needed for the build job; ensure the permissions block is
placed under the jobs.build definition so the build job runs with the minimal
token privileges.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/build-image.yml:
- Around line 37-50: The workflow currently allows non-PR manual runs
(workflow_dispatch) to log in and push images, so update the conditional guards
to restrict pushes to only the main branch (or proper release refs);
specifically, change the `if` on the "Log in to Quay.io" step and the `push`
expression on the "Build and push" step to include a ref check (e.g., require
github.ref == 'refs/heads/main' or allow refs/tags/* as appropriate) instead of
only checking github.event_name != 'pull_request', so manual runs on feature
branches cannot authenticate and push `latest`.
- Around line 25-32: The current "Set image tags" step (id: tags) builds TAGS
using date +%Y%m%d which is not unique per run; update the tag generation for
the TAGS variable to include a unique component (e.g., use date +%Y%m%d%H%M%S or
append github.run_id or GITHUB_RUN_NUMBER or a short GITHUB_SHA) so same-day
builds won't collide; modify the line that sets TAGS in that step to incorporate
the chosen unique token while keeping the existing latest and tag-ref behavior.
- Around line 22-46: The workflow uses mutable action tags (actions/checkout@v5,
docker/setup-buildx-action@v4, docker/login-action@v3,
docker/build-push-action@v6); replace each with the corresponding commit SHA for
that action to pin to an immutable revision: update the uses lines for
actions/checkout, docker/setup-buildx-action, docker/login-action, and
docker/build-push-action to use the specific commit SHAs (found from each repo’s
releases or tags) instead of the `@vX` tags, committing the updated workflow to
lock the supply chain.

---

Nitpick comments:
In @.github/workflows/build-image.yml:
- Around line 18-20: The workflow is missing an explicit least-privilege
permissions block for the build job; add a permissions entry scoped to only the
GitHub token privileges required by this job (attach a permissions map under the
build job or at workflow root) and restrict each scope (e.g., contents,
packages, pull-requests, id-token, etc.) to read or write only as needed for the
build job; ensure the permissions block is placed under the jobs.build
definition so the build job runs with the minimal token privileges.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 576fd8ea-68cb-4322-8336-c15134743b00

📥 Commits

Reviewing files that changed from the base of the PR and between 6c22802 and e1c5854.

📒 Files selected for processing (1)
  • .github/workflows/build-image.yml

Comment on lines +22 to +46
- name: Checkout
uses: actions/checkout@v5

- name: Set image tags
id: tags
run: |
TAGS="${IMAGE}:latest,${IMAGE}:$(date +%Y%m%d)"
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
TAGS="${TAGS},${IMAGE}:${GITHUB_REF_NAME}"
fi
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4

- name: Log in to Quay.io
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: quay.io
username: ${{ secrets.QUAY_USERNAME }}
password: ${{ secrets.QUAY_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v6
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify mutable action refs in workflows
rg -nP '^\s*uses:\s*[^@]+@(?:v?\d+(?:\.\d+){0,2}|main|master)\s*$' .github/workflows

Repository: redhat-et/openclaw-infra

Length of output: 372


Pin GitHub Actions by commit SHA to reduce supply-chain risk.

All four actions use mutable version tags (@v5, @v4, @v3, @v6), allowing upstream retargeting. Pin each to a specific commit SHA instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/build-image.yml around lines 22 - 46, The workflow uses
mutable action tags (actions/checkout@v5, docker/setup-buildx-action@v4,
docker/login-action@v3, docker/build-push-action@v6); replace each with the
corresponding commit SHA for that action to pin to an immutable revision: update
the uses lines for actions/checkout, docker/setup-buildx-action,
docker/login-action, and docker/build-push-action to use the specific commit
SHAs (found from each repo’s releases or tags) instead of the `@vX` tags,
committing the updated workflow to lock the supply chain.

@sallyom sallyom force-pushed the main branch 3 times, most recently from 2cce133 to 61d8026 Compare March 6, 2026 05:26
Builds the container image nightly and on Dockerfile changes to main,
pushing to quay.io/aicatalyst/openclaw. PRs with Dockerfile changes
trigger build-only (no push).

Required GitHub repository secrets:
  QUAY_USERNAME  - Quay.io robot account or username
  QUAY_PASSWORD  - Quay.io robot account token or password

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In @.github/workflows/build-image.yml:
- Around line 29-31: The conditional checking refs/tags/v* is unreachable
because the workflow's push trigger only includes branches: [main]; either
enable tag pushes or remove the dead branch: update the workflow's on.push
configuration to include tags (for example add a tags pattern like v* or add a
separate push.tags entry) so that the refs/tags/v* condition can be true, or if
you don't want tag-triggered builds remove the TAGS append block entirely;
locate the block with the refs/tags/v* condition and either add tag patterns to
the push trigger or delete that conditional and its TAGS logic accordingly.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6e2a9e88-3155-4fec-b9e1-c3d53d0da4b3

📥 Commits

Reviewing files that changed from the base of the PR and between e1c5854 and 62d63df.

📒 Files selected for processing (1)
  • .github/workflows/build-image.yml

Comment on lines +29 to +31
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
TAGS="${TAGS},${IMAGE}:${GITHUB_REF_NAME}"
fi
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Tag version logic is unreachable — workflow never triggers on tag pushes.

The push trigger (lines 6-9) only fires for branches: [main]. Since there's no tags: filter, this refs/tags/v* condition will never match, making these lines dead code.

If you intend to publish versioned images on tag pushes, add a tags trigger:

Proposed fix to enable tag-triggered builds
 on:
   schedule:
     - cron: '0 3 * * *'  # Nightly at 3:00 UTC
   push:
     branches: [main]
+    tags:
+      - 'v*'
     paths:
       - 'Dockerfile'

Alternatively, remove the dead code if versioned tag publishing is not needed.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if [[ "${{ github.ref }}" == refs/tags/v* ]]; then
TAGS="${TAGS},${IMAGE}:${GITHUB_REF_NAME}"
fi
on:
schedule:
- cron: '0 3 * * *' # Nightly at 3:00 UTC
push:
branches: [main]
tags:
- 'v*'
paths:
- 'Dockerfile'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/build-image.yml around lines 29 - 31, The conditional
checking refs/tags/v* is unreachable because the workflow's push trigger only
includes branches: [main]; either enable tag pushes or remove the dead branch:
update the workflow's on.push configuration to include tags (for example add a
tags pattern like v* or add a separate push.tags entry) so that the refs/tags/v*
condition can be true, or if you don't want tag-triggered builds remove the TAGS
append block entirely; locate the block with the refs/tags/v* condition and
either add tag patterns to the push trigger or delete that conditional and its
TAGS logic accordingly.

- Add least-privilege permissions (contents: read) to build job
- Make image tags unique per run by appending short commit SHA
- Restrict image push and registry login to main branch only

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

♻️ Duplicate comments (2)
.github/workflows/build-image.yml (2)

27-36: ⚠️ Potential issue | 🟠 Major

DATE_TAG + short SHA still isn't unique per run.

A rerun, nightly job, and manual dispatch for the same commit on the same day all publish the same ${DATE_TAG}-${SHA_TAG} tag, so one run overwrites the previous image. Add a run-unique suffix such as GITHUB_RUN_ID or GITHUB_RUN_NUMBER.

Suggested change
-          DATE_TAG="$(date -u +%Y%m%d)"
-          SHA_TAG="${GITHUB_SHA::7}"
-          TAGS="${IMAGE}:latest,${IMAGE}:${DATE_TAG}-${SHA_TAG}"
+          DATE_TAG="$(date -u +%Y%m%d)"
+          SHA_TAG="${GITHUB_SHA::7}"
+          RUN_TAG="${GITHUB_RUN_ID}"
+          TAGS="${IMAGE}:latest,${IMAGE}:${DATE_TAG}-${SHA_TAG}-${RUN_TAG}"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/build-image.yml around lines 27 - 36, The current tag
generation (variables DATE_TAG and SHA_TAG producing TAGS) can collide across
runs; update the TAGS computation to append a run-unique suffix (use
GITHUB_RUN_ID or GITHUB_RUN_NUMBER) to the DATE_TAG-SHA_TAG token so each
workflow invocation produces a distinct tag; specifically modify the TAGS
assignment that builds "${IMAGE}:${DATE_TAG}-${SHA_TAG}" to include
"-${GITHUB_RUN_ID}" (or "-${GITHUB_RUN_NUMBER}") and ensure the new value is
what gets echoed to GITHUB_OUTPUT under the tags step.

25-25: ⚠️ Potential issue | 🟠 Major

Pin each GitHub Action to an immutable commit SHA.

@v5 / @v4 / @v3 / @v6 are still mutable refs. That leaves the workflow exposed to upstream retargeting and makes builds less reproducible. Replace each uses: version tag with the full release commit SHA instead.

What commit SHAs correspond to the current stable releases of actions/checkout v5, docker/setup-buildx-action v4, docker/login-action v3, and docker/build-push-action v6?

Also applies to: 39-39, 43-43, 50-50

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/build-image.yml at line 25, Replace mutable version tags
(`@v5`, `@4`, `@v3`, `@v6`) with the corresponding immutable commit SHAs for each GitHub
Action usage so the workflow is hermetic; specifically update the uses entries
for actions/checkout, docker/setup-buildx-action, docker/login-action, and
docker/build-push-action in the workflow (the lines currently using "uses:
actions/checkout@v5", "uses: docker/setup-buildx-action@v4", "uses:
docker/login-action@v3", and "uses: docker/build-push-action@v6") to reference
the full commit SHA of the release you want to pin, verify the SHAs against the
official action repos/tags, and replace the tags with those SHAs across the
workflow.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In @.github/workflows/build-image.yml:
- Around line 27-36: The current tag generation (variables DATE_TAG and SHA_TAG
producing TAGS) can collide across runs; update the TAGS computation to append a
run-unique suffix (use GITHUB_RUN_ID or GITHUB_RUN_NUMBER) to the
DATE_TAG-SHA_TAG token so each workflow invocation produces a distinct tag;
specifically modify the TAGS assignment that builds
"${IMAGE}:${DATE_TAG}-${SHA_TAG}" to include "-${GITHUB_RUN_ID}" (or
"-${GITHUB_RUN_NUMBER}") and ensure the new value is what gets echoed to
GITHUB_OUTPUT under the tags step.
- Line 25: Replace mutable version tags (`@v5`, `@4`, `@v3`, `@v6`) with the
corresponding immutable commit SHAs for each GitHub Action usage so the workflow
is hermetic; specifically update the uses entries for actions/checkout,
docker/setup-buildx-action, docker/login-action, and docker/build-push-action in
the workflow (the lines currently using "uses: actions/checkout@v5", "uses:
docker/setup-buildx-action@v4", "uses: docker/login-action@v3", and "uses:
docker/build-push-action@v6") to reference the full commit SHA of the release
you want to pin, verify the SHAs against the official action repos/tags, and
replace the tags with those SHAs across the workflow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6f3cbc5b-7016-45a0-a58f-5eb0fb4c2541

📥 Commits

Reviewing files that changed from the base of the PR and between 62d63df and e07e1f3.

📒 Files selected for processing (1)
  • .github/workflows/build-image.yml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant