Add CI pipeline to build image #13
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 | |
strategy: | |
matrix: | |
environment: ['devnet', 'sepolia', 'mainnet'] | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
- 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: Get changed files | |
id: changed-files | |
uses: tj-actions/changed-files@v40 | |
with: | |
files: | | |
linea-besu/build-*.json | |
# - name: Download and Prepare Artifacts | |
# run: | | |
# CONFIG_FILE="linea-besu/build-${{ matrix.environment }}.json" | |
# mkdir -p besu/${{ matrix.environment }}/plugins besu/${{ matrix.environment }}/profiles besu/${{ matrix.environment }}/config besu/${{ matrix.environment }}/genesis | |
# jq -c '.modules[]' "$CONFIG_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/${{ matrix.environment }}/${outputDir}" | |
# ;; | |
# "download") | |
# curl -L "${url/\{version\}/$version}" -o "besu/${{ matrix.environment }}/${outputDir}/$name-$version.jar" | |
# ;; | |
# "copy") | |
# cp -r "$name" "besu/${{ matrix.environment }}/${outputDir}" | |
# ;; | |
# esac | |
# done | |
# shell: /usr/bin/bash -e {0} | |
- name: Define Artifact Versions | |
id: artifact-versions | |
run: | | |
CONFIG_FILE="linea-besu/build-${{ matrix.environment }}.json" | |
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 "linea_besu_version=$linea_besu_version" >> $GITHUB_ENV | |
echo "linea_sequencer_version=$linea_sequencer_version" >> $GITHUB_ENV | |
echo "finalized_tag_updater_version=$finalized_tag_updater_version" >> $GITHUB_ENV | |
- name: Build and push Docker image | |
if: steps.changed-files.outputs.any_changed == 'true' | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: docker/Dockerfile | |
push: true | |
tags: | | |
linea-besu-package:${{ matrix.environment }}-${{ env.linea_besu_version }}-${{ env.linea_sequencer_version }}-${{ env.finalized_tag_updater_version }} |