Skip to content

Commit

Permalink
feat: add github workflow to publish composedb-cli image (#219)
Browse files Browse the repository at this point in the history
* feat: add github workflow to publish composedb-cli image

fix: add EOF space

fix: use the right image name

fix: update to use the version from supplied branch

* feat: tag latest on main branch
  • Loading branch information
3benbox authored Mar 21, 2024
1 parent 9405b98 commit 5264d35
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/docker-cli.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build and Push composed-cli Docker Image

on:
workflow_dispatch:
inputs:
branch:
description: "Branch name"
default: "main"
required: true

env:
DOCKER_IMAGE: ceramicnetwork/composedb-cli

jobs:
build-and-push:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch }}

- name: Read package.json
id: package-version
run: echo "::set-output name=version::$(jq -r '.version' ./packages/cli/package.json)"

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

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
push: true
build-args: |
VERSION=${{ steps.package-version.outputs.version }}
tags: ${{ env.DOCKER_IMAGE }}:${{ steps.package-version.outputs.version }}

- name: Push Docker image with latest tag (if default branch)
if: github.event.inputs.branch == 'main'
run: |
docker tag ${{ env.DOCKER_IMAGE }}:${{ steps.extract_version.outputs.version }} ${{ env.DOCKER_IMAGE }}:latest
docker push ${{ env.DOCKER_IMAGE }}:latest
5 changes: 5 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM node:20
ARG COMPOSEDB_CLI_VERSION=latest
RUN npm install --location=global @composedb/cli@${COMPOSEDB_CLI_VERSION}

ENTRYPOINT ["composedb"]

0 comments on commit 5264d35

Please sign in to comment.