Skip to content

Add CI pipeline to build image #6

Add CI pipeline to build image

Add CI pipeline to build image #6

Workflow file for this run

name: Build Image
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Install jq
run: sudo apt-get update && sudo apt-get install -y jq
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USER_RW }}
password: ${{ secrets.DOCKER_PAT_RW }}
- name: Check modified files
id: files
run: |
echo "CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | grep 'build-.*\.json' | xargs)" >> $GITHUB_ENV
- name: Download and Prepare Artifacts
run: |
CONFIG_FILE="build-${{ matrix.environment }}.json"
if echo "${{ env.CHANGED_FILES }}" | grep -q "$CONFIG_FILE"; then
mkdir -p besu/${{ matrix.environment }}/plugins besu/${{ matrix.environment }}/profiles besu/${{ matrix.environment }}/config besu/${{ matrix.environment }}/genesis
# Your existing jq and curl commands adjusted for dynamic paths...
- name: Define Artifact Versions
id: artifact-versions
run: |
CONFIG_FILE="build-${{ matrix.environment }}.json"
if echo "${{ env.CHANGED_FILES }}" | grep -q "$CONFIG_FILE"; then
linea_besu_version=$(jq -r '.modules[] | select(.name=="linea-besu") | .version' $CONFIG_FILE)
linea_sequencer_version=$(jq -r '.modules[] | select(.name=="linea-sequencer") | .version' $CONFIG_FILE)
finalized_tag_updater_version=$(jq -r '.modules[] | select(.name=="finalized-tag-updater") | .version' $CONFIG_FILE)
echo "::set-output name=linea_besu_version::$linea_besu_version"
echo "::set-output name=linea_sequencer_version::$linea_sequencer_version"
echo "::set-output name=finalized_tag_updater_version::$finalized_tag_updater_version"
- name: Build and push Docker image
if: contains(env.CHANGED_FILES, 'build-${{ matrix.environment }}.json')
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
linea-besu-package:${{ matrix.environment }}-${{ steps.artifact-versions.outputs.linea_besu_version }}-${{ steps.artifact-versions.outputs.linea_sequencer_version }}-${{ steps.artifact-versions.outputs.finalized_tag_updater_version }}