Skip to content

Commit

Permalink
feat(CD): Publish relayer images when new tag is pushed (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
mertwole authored Nov 4, 2024
1 parent ab6d90c commit e6612dd
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 29 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build-and-publish-relayer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: build_and_publish_relayer

on:
workflow_call:
inputs:
tags:
type: string

jobs:
build-and-publish:
runs-on: kuberunner
steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Log in to gchr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
file: ./Dockerfile
push: true
tags: ${{ inputs.tags }}
cache-from: type=gha
cache-to: type=gha,mode=max
42 changes: 13 additions & 29 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches:
- main
tags:
- 'v*'
workflow_dispatch:

concurrency:
Expand All @@ -14,32 +16,14 @@ env:
CARGO_TERM_COLOR: always

jobs:
build:
runs-on: kuberunner
steps:
- name: Checkout code
uses: actions/checkout@v4

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

- name: Prepare Docker Tags
id: docker_meta
run: |
echo "DOCKER_TAGS=ghcr.io/gear-tech/bridge-relayer:${{ github.ref_name }}.${{ github.sha }},ghcr.io/gear-tech/bridge-relayer:latest" >> $GITHUB_ENV
- name: Log in to gchr.io
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
file: ./Dockerfile
push: true
tags: ${{ env.DOCKER_TAGS }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-and-publish-relayer:
if: ${{ ! startsWith(github.ref, 'refs/tags/') }}
uses: ./.github/workflows/build-and-publish-relayer.yml
with:
tags: ghcr.io/gear-tech/bridge-relayer:${{ github.ref_name }}.${{ github.sha }}

build-and-publish-relayer-release:
if: startsWith(github.ref, 'refs/tags/')
uses: ./.github/workflows/build-and-publish-relayer.yml
with:
tags: ghcr.io/gear-tech/bridge-relayer:latest,ghcr.io/gear-tech/bridge-relayer:${{ github.ref_name }}

0 comments on commit e6612dd

Please sign in to comment.