Add CI pipeline to build image #2
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 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_REPO_USER }} | |
password: ${{ secrets.DOCKER_REPO_TOKEN }} | |
- 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 | |
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 }} |