Skip to content

Commit

Permalink
Add docker build gha
Browse files Browse the repository at this point in the history
  • Loading branch information
simisimis committed Feb 17, 2025
1 parent 57d7bee commit 1e67322
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 19 deletions.
69 changes: 69 additions & 0 deletions .github/workflows/publish-image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
name: Publish to docker.io

on:
push:
tags:
- '*'
workflow_dispatch:
inputs:
docker_tag_prefix:
description: "Enter the Docker Tag Prefix (e.g adhoc-test)"
required: true
type: string
mina_rosetta_image:
description: "Enter mina-rosetta image:tag"
required: true
type: string
env:
ECR_REPOSITORY_URL: 673156464838.dkr.ecr.us-west-2.amazonaws.com
ECR_REPOSITORY_NAME: uptime-service-backend
DOCKER_TAG_PREFIX: ${{ github.event.inputs.docker_tag_prefix }}
MINA_ROSETTA_IMAGE: ${{ github.event.inputs.mina_rosetta_image }}

# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.head_ref || github.ref }}'
cancel-in-progress: true

jobs:
build-docker-image:
name: Build and Push Docker Image
runs-on: minafoundation-default-runners
steps:
- name: 📥 Checkout
uses: actions/checkout@v4
- name: 🏷️ Generate Tag
run: |
BRANCH_OR_TAG=$(basename ${{ github.ref }})
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
PREFIX=${{ env.DOCKER_TAG_PREFIX }}
SHORT_SHA=$(echo $GITHUB_SHA | cut -c1-7)
echo "TAG=$PREFIX-$BRANCH_OR_TAG-$SHORT_SHA" >> $GITHUB_ENV
elif [ "${{ github.event_name }}" == "push" ] && [ -n "${{ github.event.ref }}" ]; then

Check warning on line 42 in .github/workflows/publish-image.yaml

View workflow job for this annotation

GitHub Actions / cspell

Unknown word (elif)
echo "TAG=$BRANCH_OR_TAG" >> $GITHUB_ENV
else
echo "Invalid event. Exiting..."
exit 1
fi
- name: 🔑 docker.io Login
uses: docker/login-action@v3
with:
username: minafoundation
password: ${{ secrets.DOCKER_IO_TOKEN }}
- name: 🔍 Check if Tag already exists
id: checktag

Check warning on line 54 in .github/workflows/publish-image.yaml

View workflow job for this annotation

GitHub Actions / cspell

Unknown word (checktag)
uses: tyriis/docker-image-tag-exists@v2.0.1

Check warning on line 55 in .github/workflows/publish-image.yaml

View workflow job for this annotation

GitHub Actions / cspell

Unknown word (tyriis)
with:
registry: docker.io
repository: minafoundation/mina-mesh
tag: ${{ env.TAG }}
- name: Set up Docker Buildx

Check warning on line 60 in .github/workflows/publish-image.yaml

View workflow job for this annotation

GitHub Actions / cspell

Unknown word (Buildx)
if: steps.checktag.outputs.tag == 'not found'

Check warning on line 61 in .github/workflows/publish-image.yaml

View workflow job for this annotation

GitHub Actions / cspell

Unknown word (checktag)
uses: docker/setup-buildx-action@v3

Check warning on line 62 in .github/workflows/publish-image.yaml

View workflow job for this annotation

GitHub Actions / cspell

Unknown word (buildx)
- name: 🛠️ build and push 🚚 Mina Mesh Docker Image
if: steps.checktag.outputs.tag == 'not found'

Check warning on line 64 in .github/workflows/publish-image.yaml

View workflow job for this annotation

GitHub Actions / cspell

Unknown word (checktag)
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: minafoundation/mina-mesh:${{ env.TAG }}
19 changes: 0 additions & 19 deletions .github/workflows/publish.yaml

This file was deleted.

0 comments on commit 1e67322

Please sign in to comment.