added docker build
This commit is contained in:
113
.github/workflows/build-opencode-cli-docker.yml
vendored
Normal file
113
.github/workflows/build-opencode-cli-docker.yml
vendored
Normal file
@@ -0,0 +1,113 @@
|
||||
name: Build OpenCode CLI and Docker Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
paths:
|
||||
- opencode/**
|
||||
- Dockerfile
|
||||
- .github/workflows/build-opencode-cli-docker.yml
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
image_name:
|
||||
description: "Docker image name (including registry if desired)"
|
||||
required: false
|
||||
default: "ghcr.io/${{ github.repository_owner }}/shopify-ai-builder"
|
||||
push_image:
|
||||
description: "Push the image to the registry"
|
||||
type: boolean
|
||||
default: false
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
packages: write
|
||||
|
||||
jobs:
|
||||
build-cli:
|
||||
name: Build OpenCode CLI (${{ matrix.arch }})
|
||||
runs-on: ${{ matrix.runner }}
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
include:
|
||||
- arch: amd64
|
||||
runner: ubuntu-24.04
|
||||
cli_dir: opencode-linux-x64
|
||||
- arch: arm64
|
||||
runner: ubuntu-24.04-arm64
|
||||
cli_dir: opencode-linux-arm64
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Bun
|
||||
uses: oven-sh/setup-bun@v2
|
||||
with:
|
||||
bun-version-file: opencode/package.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: bun install
|
||||
working-directory: opencode
|
||||
|
||||
- name: Build CLI
|
||||
run: ./packages/opencode/script/build.ts --single
|
||||
working-directory: opencode
|
||||
|
||||
- name: Upload CLI artifact
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: opencode-cli-${{ matrix.arch }}
|
||||
path: opencode/packages/opencode/dist/${{ matrix.cli_dir }}
|
||||
|
||||
build-image:
|
||||
name: Build Docker image
|
||||
needs: build-cli
|
||||
runs-on: ubuntu-24.04
|
||||
env:
|
||||
IMAGE_NAME: ${{ inputs.image_name || format('ghcr.io/{0}/shopify-ai-builder', github.repository_owner) }}
|
||||
PUSH_IMAGE: ${{ inputs.push_image || false }}
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Download CLI artifacts
|
||||
uses: actions/download-artifact@v4
|
||||
with:
|
||||
pattern: opencode-cli-*
|
||||
path: opencode/packages/opencode/dist
|
||||
merge-multiple: true
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
|
||||
- name: Login to GHCR
|
||||
if: ${{ env.PUSH_IMAGE == 'true' }}
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Build image (multi-arch push)
|
||||
if: ${{ env.PUSH_IMAGE == 'true' }}
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform linux/amd64,linux/arm64 \
|
||||
-t "$IMAGE_NAME" \
|
||||
--push \
|
||||
.
|
||||
|
||||
- name: Build image (amd64) and verify CLI
|
||||
if: ${{ env.PUSH_IMAGE != 'true' }}
|
||||
run: |
|
||||
docker buildx build \
|
||||
--platform linux/amd64 \
|
||||
-t "$IMAGE_NAME" \
|
||||
--load \
|
||||
.
|
||||
docker run --rm "$IMAGE_NAME" opencode --version
|
||||
Reference in New Issue
Block a user