Build and Push Ika Node Docker Image #12
This file contains hidden or 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 Ika Node Docker Image | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| network: | |
| description: 'The network to build the image for (mainnet, testnet, devnet)' | |
| required: true | |
| type: string | |
| options: | |
| - mainnet | |
| - testnet | |
| - devnet | |
| default: devnet | |
| version: | |
| description: 'Version to tag the image (format: vX.Y.Z)' | |
| required: true | |
| default: v1.0.0 | |
| type: string | |
| env: | |
| GH_DEPLOY_KEY: ${{ secrets.GH_DEPLOY_KEY }} | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| packages: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Validate version format | |
| run: | | |
| if [[ ! "${{ inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Error: Version must be in format vX.Y.Z (e.g., v1.0.0)" | |
| exit 1 | |
| fi | |
| echo "Version format is valid: ${{ inputs.version }}" | |
| - name: Authenticate to Google Cloud | |
| uses: 'google-github-actions/auth@v2' | |
| with: | |
| credentials_json: '${{ secrets.GAR_KEY }}' | |
| - name: 'Set up Cloud SDK' | |
| uses: 'google-github-actions/setup-gcloud@v2' | |
| - name: 'Configure Docker for Artifact Registry' | |
| run: gcloud auth configure-docker us-docker.pkg.dev | |
| - name: Setup SSH for manual git | |
| if: env.GH_DEPLOY_KEY | |
| run: | | |
| mkdir -p ~/.ssh | |
| printf "%s" "${{ secrets.GH_DEPLOY_KEY }}" > ~/.ssh/id_ed25519 | |
| chmod 600 ~/.ssh/id_ed25519 | |
| ssh-keyscan github.com >> ~/.ssh/known_hosts | |
| - name: Globally rewrite any GitHub HTTPS to SSH | |
| if: env.GH_DEPLOY_KEY | |
| run: | | |
| git config --global url."[email protected]:dwallet-labs/cryptography-private".insteadOf "https://github.com/dwallet-labs/cryptography-private" | |
| - name: 'Build and Push Docker Image' | |
| run: | | |
| set -e | |
| # Set repository details | |
| REPO_NAME="us-docker.pkg.dev/common-449616/ika-common-public-containers" | |
| IMAGE_NAME="ika-node" | |
| VERSION="${{ inputs.version }}" | |
| NETWORK="${{ inputs.network }}" | |
| DOCKER_TAG="${REPO_NAME}/${IMAGE_NAME}:${NETWORK}-${VERSION}" | |
| # Set up environment variables for build script | |
| export GH_DEPLOY_KEY="${{ secrets.GH_DEPLOY_KEY }}" | |
| export DOCKER_TAG | |
| # Prepare build flags | |
| BUILD_FLAGS="" | |
| # Navigate to docker build directory | |
| cd docker/ika-node | |
| # Build the Docker image using build.sh | |
| echo "Building Docker image: ${DOCKER_TAG}" | |
| ./build.sh $BUILD_FLAGS | |
| # Push both tags | |
| echo "Pushing Docker image: ${DOCKER_TAG}" | |
| docker push ${DOCKER_TAG} | |
| echo "Successfully built and pushed:" | |
| echo "- ${DOCKER_TAG}" |