Skip to content

Build and push image to ECR #24

Build and push image to ECR

Build and push image to ECR #24

Workflow file for this run

---
name: Build and push image to ECR
on:
workflow_dispatch:
inputs:
network_name:
description: "Enter the Network Name (berkeley or mainnet)"
required: true
type: string
default: mainnet
docker_base_tag_prefix:
description: "Enter the Base Tag Prefix (e.g itn-preprod)"
required: true
type: string
env:
NETWORK_NAME: ${{ github.event.inputs.network_name }}
DOCKER_BASE_TAG_PREFIX: ${{ github.event.inputs.docker_base_tag_prefix }}
WORKFLOW_SHA: ${{ github.sha }}
FUNCTIONS: ./.github/workflows/helpers/functions.sh
VARIABLES: ./.github/workflows/helpers/variables.sh
# This allows a subsequently queued workflow run to interrupt previous runs
concurrency:
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || 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@v3
with:
submodules: recursive
- name: 📥 Login to Amazon ECR
uses: aws-actions/amazon-ecr-login@v1
- name: ⚙ Get Short Commit SHA and Get Image Tag
id: short-commit-sha
run: |
source ${{ env.FUNCTIONS }}
echo "TAG=${{ env.DOCKER_BASE_TAG_PREFIX }}-$(shorten_commit_sha ${{ env.WORKFLOW_SHA }})-${{ env.NETWORK_NAME }}" >> $GITHUB_ENV
- name: 📦 Install Nix
uses: cachix/install-nix-action@v22
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: 🛠️ Build BPU Docker Image
run: |
TAG=${{ env.TAG }}
nix-shell --run "make docker"
- name: 📤 Push BPU Docker Image
run: |
source ${{ env.VARIABLES }}
docker push $ECR_REGISTRY_URL/block-producers-uptime:${{ env.TAG }}