-
Notifications
You must be signed in to change notification settings - Fork 32
53 lines (44 loc) · 1.55 KB
/
docker-cli.yaml
File metadata and controls
53 lines (44 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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: |
set -x
echo "version=$(jq -r '.version' ./packages/cli/package.json)" >> $GITHUB_OUTPUT
- 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: |
COMPOSEDB_CLI_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 pull ${{ env.DOCKER_IMAGE }}:${{ steps.package-version.outputs.version }}
docker tag ${{ env.DOCKER_IMAGE }}:${{ steps.package-version.outputs.version }} ${{ env.DOCKER_IMAGE }}:latest
docker push ${{ env.DOCKER_IMAGE }}:latest