Skip to content

Commit

Permalink
reworked the docker build workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
bizk committed Sep 16, 2023
1 parent 9b62115 commit 031a2e1
Showing 1 changed file with 50 additions and 18 deletions.
68 changes: 50 additions & 18 deletions .github/workflows/build-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,67 @@ name: Build rosetta docker container
# This workflow is run on pushes to main & every Pull Requests where a .go, .mod, .sum have been changed
on:
pull_request:
merge_group:
paths:
- "Dockerfile"
push:
branches:
- main
- release/**
tags:
- "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10
- "v[0-9]+.[0-9]+.[0-9]+-rc*" # Push events to matching v*, i.e. v1.0-rc1, v20.15.10-rc5
workflow_dispatch:
inputs:
tags:
description: "Rosetta version (e.g 0.47.1)"
required: true
type: string

permissions:
contents: read
packages: write

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: cosmos/rosetta

jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Set up Docker Buildx
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=semver,pattern=v{{major}}.{{minor}}
type=semver,pattern={{version}},value=v${{ inputs.tags }},enable=${{ inputs.tags != '' }}
flavor: |
latest=false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name: Build and push

- name: Log into registry ${{ env.REGISTRY }}
if: ${{ github.event_name != 'pull_request' }}
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Publish to GitHub Packages
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: false
tags: ${{ secrets.DOCKERHUB_USERNAME }}/clockbox:latest
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit 031a2e1

Please sign in to comment.