Commit id a6c88741cbc42f3cc9b7617fa45619c2d4c2bc83: CI-CD build and deploy docker images based on the commit id in the main branch #21
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: CI-CD build and deploy docker images based on the last commit in the main branch | |
run-name: "Commit id ${{ github.sha }}: CI-CD build and deploy docker images based on the commit id in the main branch" | |
env: | |
APPLICATION: "erigon" | |
BUILDER_IMAGE: "golang:1.22.6-alpine3.20" | |
TARGET_BASE_IMAGE: "alpine:3.20.2" | |
APP_REPO: "erigontech/erigon" | |
CHECKOUT_REF: "main" | |
DOCKERHUB_REPOSITORY: "erigontech/erigon" | |
LABEL_DESCRIPTION: "[docker image built on a last commit id from the main branch] Erigon is an implementation of Ethereum (execution layer with embeddable consensus layer), on the efficiency frontier. Archive Node by default." | |
on: | |
push: | |
branches: | |
- 'main' | |
paths-ignore: | |
- '.github/**' | |
workflow_dispatch: | |
jobs: | |
Build: | |
runs-on: ubuntu-22.04 | |
timeout-minutes: 45 | |
steps: | |
- name: Fast checkout git repository | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 ## 4.1.7 release | |
with: | |
repository: ${{ env.APP_REPO }} | |
fetch-depth: 1 | |
ref: ${{ env.CHECKOUT_REF }} | |
path: 'erigon' | |
- name: Get commit id | |
id: getCommitId | |
run: | | |
cd erigon | |
echo "id=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT | |
echo "short_commit_id=$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT | |
cd .. | |
- name: Login to Docker Hub | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 ## v3.3.0 | |
with: | |
username: ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_USERNAME }} | |
password: ${{ secrets.ORG_DOCKERHUB_ERIGONTECH_TOKEN }} | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@49b3bc8e6bdd4a60e6116a5414239cba5943d3cf ## v3.2.0 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@988b5a0280414f521da01fcc63a27aeeb4b104db ## v3.6.1 | |
- name: Build and push multi-platform docker image based on the commit id ${{ steps.getCommitId.outputs.short_commit_id }} in the main branch | |
env: | |
BUILD_VERSION: "main-${{ steps.getCommitId.outputs.short_commit_id }}" | |
DOCKER_URL: ${{ env.DOCKERHUB_REPOSITORY }} | |
DOCKERFILE_PATH: Dockerfile.release | |
run: | | |
cd erigon | |
docker buildx build \ | |
--file ${{ env.DOCKERFILE_PATH }} \ | |
--target ci-cd-main-branch \ | |
--build-arg CI_CD_MAIN_TARGET_BASE_IMAGE=${{ env.TARGET_BASE_IMAGE }} \ | |
--build-arg CI_CD_MAIN_BUILDER_IMAGE=${{ env.BUILDER_IMAGE }} \ | |
--tag ${{ env.DOCKER_URL }}:${{ env.BUILD_VERSION }} \ | |
--tag ${{ env.DOCKER_URL }}:main-latest \ | |
--label org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \ | |
--label org.opencontainers.image.authors="https://github.com/erigontech/erigon/graphs/contributors" \ | |
--label org.opencontainers.image.url="https://github.com/erigontech/erigon/blob/main/Dockerfile" \ | |
--label org.opencontainers.image.documentation="https://github.com/erigontech/erigon/blob/main/Dockerfile" \ | |
--label org.opencontainers.image.source="https://github.com/erigontech/erigon/blob/main/Dockerfile" \ | |
--label org.opencontainers.image.version=${{ steps.getCommitId.outputs.id }} \ | |
--label org.opencontainers.image.revision=${{ steps.getCommitId.outputs.id }} \ | |
--label org.opencontainers.image.vcs-ref-short=${{ steps.getCommitId.outputs.short_commit_id }} \ | |
--label org.opencontainers.image.vendor="${{ github.repository_owner }}" \ | |
--label org.opencontainers.image.description="${{ env.LABEL_DESCRIPTION }}" \ | |
--label org.opencontainers.image.base.name="${{ env.TARGET_BASE_IMAGE }}" \ | |
--push \ | |
--platform linux/amd64,linux/arm64 . | |
- name: Print docker images published | |
run: | | |
echo The following docker images have been published: | |
echo "${{ env.DOCKERHUB_REPOSITORY }}:main-${{ steps.getCommitId.outputs.short_commit_id }}" | |
echo "${{ env.DOCKERHUB_REPOSITORY }}:main-latest" | |