Skip to content

Removed useless blank line #1171

Removed useless blank line

Removed useless blank line #1171

Workflow file for this run

---
name: Build docker image
on:
push:
tags:
- "v*"
branches:
- "dockerbuild"
- "develop"
- "release/v*"
- "feature/*"
workflow_dispatch:
inputs:
geth_version:
description: 'The Geth version to build from'
required: true
default: 'latest-fh2'
flavors:
description: 'JSON-formatted list of flavors to build'
required: true
default: '["geth","bsc","polygon"]' # careful, this value is not used in automatic triggers, this value is repeated in step bundle-docker-versions
type: string
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-vanilla:
runs-on: ubuntu-20.04
permissions:
contents: read
packages: write
strategy:
matrix:
go-version: [1.20.x]
outputs:
tags: ${{ steps.meta.outputs.tags }}
env:
SLACK_IDS: ${{ vars.SLACK_IDS }}
steps:
- uses: actions/checkout@v3
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}
- uses: actions/cache@v3
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Branch name
id: extract_branch
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "##[set-output name=release_train;]$(echo ${GITHUB_REF#refs/heads/release/})"
- name: Build
run: go build -v -ldflags "-X main.version=${{ github.event.ref }}" -o ./fireeth ./cmd/fireeth
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Generate docker tags/labels from github build context
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag
type=sha,prefix=,enable=true
type=raw,enable=${{ github.ref == 'refs/heads/develop' }},value=develop
type=raw,enable=${{ startsWith(github.ref, 'refs/heads/release/v') }},value=${{ steps.extract_branch.outputs.release_train }}
flavor: |
latest=${{ startsWith(github.ref, 'refs/tags/') }}
- name: Check SLACK_IDS env variable
run: |
if [ -z "${SLACK_IDS}" ]; then
echo "SLACK_IDS is empty"
exit 1
fi
- name: Get Slack ID
id: get-slack-id
run: |
SLACK_IDS=$(echo "$SLACK_IDS" | sed 's/\\//g')
SLACK_ID=$(echo "$SLACK_IDS" | jq -r ".${{ github.actor }}")
echo "SLACK_ID=$SLACK_ID"
echo "::set-output name=SLACK_ID::$SLACK_ID"
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Notify build failure on Slack
if: ${{ failure() }}
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: Ilshidur/[email protected]
with:
args: |
:x: <@${{ steps.get-slack-id.outputs.SLACK_ID }}> *${{ github.repository }}* Failed building docker image from ${{ github.ref_type }} _${{ github.ref_name }}_ (${{ github.actor }}) :broken_heart:
bundle-docker-versions:
needs: build-vanilla
runs-on: ubuntu-20.04
if: ${{ startsWith(github.ref, 'refs/tags/') || contains(github.event.head_commit.message, 'build:all') || github.event_name == 'workflow_dispatch' }}
permissions:
contents: read
packages: write
outputs:
geth: ${{ steps.print.outputs.geth }}
bsc: ${{ steps.print.outputs.bsc }}
polygon: ${{ steps.print.outputs.polygon }}
strategy:
matrix:
binary: ${{ fromJSON(github.event.inputs.flavors || '["geth","bsc","polygon"]' ) }}
env:
SLACK_IDS: ${{ vars.SLACK_IDS }}
steps:
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Branch name
id: extract_branch
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "##[set-output name=release_train;]$(echo ${GITHUB_REF#refs/heads/release/})"
- run: |
docker pull ghcr.io/streamingfast/go-ethereum:${{ matrix.binary }}-${GETH_VERSION:-latest-fh2}
echo VERSION=$(docker inspect --format='{{index .Config.Labels "org.opencontainers.image.version"}}' 'ghcr.io/streamingfast/go-ethereum':${{ matrix.binary }}-${GETH_VERSION:-latest-fh2}) >> $GITHUB_ENV
echo SF_VERSION=$(echo "${{ needs.build-vanilla.outputs.tags }}" | grep -Ev "(develop|0.1[01].x)" | head -n 1 |cut -d: -f2) >> $GITHUB_ENV
env:
GETH_VERSION: ${{ github.event.inputs.geth_version }}
- name: Generate docker tags/labels from github build context
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=tag,suffix=-${{ env.VERSION }}
type=ref,event=tag,suffix=-${{ matrix.binary }}
type=sha,prefix=,suffix=-${{ env.VERSION }},enable=true
type=sha,prefix=,suffix=-${{ matrix.binary }},enable=true
type=raw,prefix=,suffix=-${{ env.VERSION }},enable=${{ github.ref == 'refs/heads/develop' }},value=develop
type=raw,prefix=,suffix=-${{ matrix.binary }},enable=${{ github.ref == 'refs/heads/develop' }},value=develop
type=raw,prefix=,suffix=-${{ env.VERSION }},enable=${{ github.ref == 'refs/heads/dockerbuild' }},value=manual
type=raw,prefix=,suffix=-${{ matrix.binary }},enable=${{ github.ref == 'refs/heads/dockerbuild' }},value=manual
type=raw,prefix=,suffix=-${{ env.VERSION }},enable=${{ startsWith(github.ref, 'refs/heads/release/v') }},value=${{ steps.extract_branch.outputs.release_train }}
type=raw,prefix=,suffix=-${{ matrix.binary }},enable=${{ startsWith(github.ref, 'refs/heads/release/v') }},value=${{ steps.extract_branch.outputs.release_train }}
flavor: latest=false
- name: Check SLACK_IDS env variable
run: |
if [ -z "${SLACK_IDS}" ]; then
echo "SLACK_IDS is empty"
exit 1
fi
- name: Get Slack ID
id: get-slack-id
run: |
SLACK_IDS=$(echo "$SLACK_IDS" | sed 's/\\//g')
SLACK_ID=$(echo "$SLACK_IDS" | jq -r ".${{ github.actor }}")
echo "SLACK_ID=$SLACK_ID"
echo "::set-output name=SLACK_ID::$SLACK_ID"
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
file: ./Dockerfile.bundle
build-args: |
CHAIN_VERSION=${{ env.VERSION }}
SF_VERSION=${{ env.SF_VERSION }}
- name: Notify build failure on Slack
if: ${{ failure() }}
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: Ilshidur/[email protected]
with:
args: |
:x: <@${{ steps.get-slack-id.outputs.SLACK_ID }}> *${{ github.repository }}* Failed bundling docker versions from ${{ github.ref_type }} _${{ github.ref_name }}_ (${{ github.actor }}) :broken_heart:
- id: print
run: |
OUT="${{ steps.meta.outputs.tags }}"
OUT="${OUT//'%'/'%25'}"
OUT="${OUT//$'\n'/' '}"
OUT="${OUT//$'\r'/' '}"
echo "${{ matrix.binary }}=$OUT" >> $GITHUB_OUTPUT
slack-notifications-vanilla:
if: ${{ !startsWith(github.ref, 'refs/tags/') && !contains(github.event.head_commit.message, 'build:all') && github.event_name != 'workflow_dispatch' }}
needs: [build-vanilla]
runs-on: ubuntu-20.04
env:
SLACK_IDS: ${{ vars.SLACK_IDS }}
steps:
- name: Get Slack ID
id: get-slack-id
run: |
SLACK_IDS=$(echo "$SLACK_IDS" | sed 's/\\//g')
SLACK_ID=$(echo "$SLACK_IDS" | jq -r ".${{ github.actor }}")
echo "SLACK_ID=$SLACK_ID"
echo "::set-output name=SLACK_ID::$SLACK_ID"
- name: Slack notification
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: Ilshidur/[email protected]
with:
args: |
:done: <@${{ steps.get-slack-id.outputs.SLACK_ID }}> *${{ github.repository }}* Success building docker image from ${{ github.ref_type }} _${{ github.ref_name }}_ (${{ github.actor }}) :sparkling_heart: ```${{ join(needs.build-vanilla.outputs.tags, ' ') }}```
slack-notifications:
needs: [ build-vanilla, bundle-docker-versions ]
runs-on: ubuntu-20.04
env:
SLACK_IDS: ${{ vars.SLACK_IDS }}
steps:
- name: Get Slack ID
id: get-slack-id
run: |
SLACK_IDS=$(echo "$SLACK_IDS" | sed 's/\\//g')
SLACK_ID=$(echo "$SLACK_IDS" | jq -r ".${{ github.actor }}")
echo "SLACK_ID=$SLACK_ID"
echo "::set-output name=SLACK_ID::$SLACK_ID"
- name: Slack notification
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
uses: Ilshidur/[email protected]
with:
args: |
:done: <@${{ steps.get-slack-id.outputs.SLACK_ID }}> *${{ github.repository }}* Success building docker images from ${{ github.ref_type }} _${{ github.ref_name }}_ (${{ github.actor }}) :sparkling_heart: ```${{ join(needs.build-vanilla.outputs.tags, ' ') }}
${{ needs.bundle-docker-versions.outputs.geth }}
${{ needs.bundle-docker-versions.outputs.bsc }}
${{ needs.bundle-docker-versions.outputs.polygon }}```