Build and Push Docker Image #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Push Docker Image | |
on: | |
workflow_dispatch: | |
inputs: | |
shardeum_branch: | |
description: 'Shardeum repository branch' | |
required: true | |
default: 'itn4-1.16.3' | |
relayer_collector_branch: | |
description: 'Relayer collector repository branch' | |
required: true | |
default: 'itn4' | |
json_rpc_server_branch: | |
description: 'JSON RPC server repository branch' | |
required: true | |
default: 'itn4' | |
image_tag: | |
description: 'Docker image tag' | |
required: true | |
default: 'itn4-1.16.3' | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-push: | |
runs-on: ubuntu-latest | |
timeout-minutes: 120 | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Log in to the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Determine architecture | |
id: arch | |
run: | | |
ARCH=$(uname -m) | |
if [ "$ARCH" == "aarch64" ] || [ "$ARCH" == "arm64" ]; then | |
echo "ARCH_TAG=arm64" >> $GITHUB_OUTPUT | |
elif [ "$ARCH" == "x86_64" ]; then | |
echo "ARCH_TAG=amd64" >> $GITHUB_OUTPUT | |
else | |
echo "Unsupported architecture: $ARCH. Exiting." | |
exit 1 | |
fi | |
- name: Build Docker image | |
run: | | |
docker build \ | |
--build-arg SHARDEUM_BRANCH=${{ inputs.shardeum_branch }} \ | |
--build-arg RELAYER_COLLECTOR_BRANCH=${{ inputs.relayer_collector_branch }} \ | |
--build-arg JSON_RPC_SERVER_BRANCH=${{ inputs.json_rpc_server_branch }} \ | |
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ steps.arch.outputs.ARCH_TAG }}:${{ inputs.image_tag }} \ | |
-t ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ steps.arch.outputs.ARCH_TAG }}:latest \ | |
. | |
- name: Push Docker image | |
run: | | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ steps.arch.outputs.ARCH_TAG }}:${{ inputs.image_tag }} | |
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}-${{ steps.arch.outputs.ARCH_TAG }}:latest |