Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add CI pipeline to build image #115

Closed
wants to merge 18 commits into from
127 changes: 127 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
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 "FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})" >> $GITHUB_ENV

- name: Download and Prepare Artifacts
run: |
if [[ -n "${{ env.CHANGED_FILES }}" ]]; then
for file in $CHANGED_FILES; do
network=$(echo "$file" | sed -E 's/build-(.*)\.json/\1/')
mkdir -p besu/$network/plugins besu/$network/profiles besu/$network/config besu/$network/genesis

jq -c '.modules[]' "$file" | while read -r module; do
type=$(echo "$module" | jq -r '.type')
name=$(echo "$module" | jq -r '.name')
url=$(echo "$module" | jq -r '.url')
version=$(echo "$module" | jq -r '.version')
outputDir=$(echo "$module" | jq -r '.outputDir // empty')

case "$type" in
"extract")
curl -L "${url/\{version\}/$version}" | tar xz -C "besu/$network/${outputDir}"
;;
"download")
curl -L "${url/\{version\}/$version}" -o "besu/$network/${outputDir}/$name-$version.jar"
;;
"copy")
cp -r "$name" "besu/$network/${outputDir}"
;;
esac
done
done
fi

- name: Define Artifact Versions devnet
naveen-consensys marked this conversation as resolved.
Show resolved Hide resolved
id: artifact-versions-devnet
if: contains(env.FILES, 'build-devnet.json')
run: |
linea_besu_version=$(jq -r '.modules[] | select(.name=="linea-besu") | .version' build-devnet.json)
linea_sequencer_version=$(jq -r '.modules[] | select(.name=="linea-sequencer") | .version' build-devnet.json)
finalized_tag_updater_version=$(jq -r '.modules[] | select(.name=="finalized-tag-updater") | .version' build-devnet.json)

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: Define Artifact Versions Sepolia
id: artifact-versions-sepolia
if: contains(env.FILES, 'build-sepolia.json')
run: |
linea_besu_version=$(jq -r '.modules[] | select(.name=="linea-besu") | .version' build-sepolia.json)
linea_sequencer_version=$(jq -r '.modules[] | select(.name=="linea-sequencer") | .version' build-sepolia.json)
finalized_tag_updater_version=$(jq -r '.modules[] | select(.name=="finalized-tag-updater") | .version' build-sepolia.json)

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: Define Artifact Versions Mainnet
id: artifact-versions-mainnet
if: contains(env.FILES, 'build-mainnet.json')
run: |
linea_besu_version=$(jq -r '.modules[] | select(.name=="linea-besu") | .version' build-mainnet.json)
linea_sequencer_version=$(jq -r '.modules[] | select(.name=="linea-sequencer") | .version' build-mainnet.json)
finalized_tag_updater_version=$(jq -r '.modules[] | select(.name=="finalized-tag-updater") | .version' build-mainnet.json)

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 for Devnet
if: contains(env.FILES, 'build-devnet.json')
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
linea-besu-package:${{ steps.artifact-versions-devnet.outputs.linea_besu_version }}-${{ steps.artifact-versions-devnet.outputs.linea_sequencer_version }}-${{ steps.artifact-versions-devnet.outputs.finalized_tag_updater_version }}

- name: Build and push Docker image for Sepolia
if: contains(env.FILES, 'build-sepolia.json')
uses: docker/build-push-action@v2
with:
context: .
file: ./Dockerfile
push: true
tags: |
linea-besu-package:${{ steps.artifact-versions-sepolia.outputs.linea_besu_version }}-${{ steps.artifact-versions-sepolia.outputs.linea_sequencer_version }}-${{ steps.artifact-versions-sepolia.outputs.finalized_tag_updater_version }}

- name: Build and push Docker image for Mainnet
if: contains(env.FILES, 'build-mainnet.json')
uses: docker/build-push-action@v2
with:
push: true
tags: |
linea-besu-package:${{ steps.artifact-versions-mainnet.outputs.linea_besu_version }}-${{ steps.artifact-versions-mainnet.outputs.linea_sequencer_version }}-${{ steps.artifact-versions-mainnet.outputs.finalized_tag_updater_version }}
2 changes: 1 addition & 1 deletion linea-besu/build-devnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "extract",
"name": "linea-besu",
"url": "https://artifacts.consensys.net/public/linea-besu/raw/names/linea-besu.tar.gz/versions/{version}/linea-besu-{version}.tar.gz",
"version": "24.10-delivery34"
"version": "24.10-delivery35"
},
{
"type": "download",
Expand Down
Loading