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 a master build docker image for each commit on master branch #5777

Merged
merged 5 commits into from
Jun 14, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 32 additions & 9 deletions .github/workflows/build-nethermind-docker-images.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
name: '[BUILD] Docker images and publish'

on:
push:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change to:

push:
  branches: [master]
paths:
  - 'src/Nethermind/**'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to have same think for tests... It triggers every time I commit :/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about adding

- '!src/Nethermind/*.Test'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will limit this one a bit.
but I meant that look below - I'd add some change to yaml and all nethermind unit tests will be triggered - this is worse than those micro optimizations :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought you mean you don't wanna trigger Docker build on any test commit. Well, if you mean that each PR commit triggers required tests, then it is what it is. As they are required, they must run anyway. Otherwise, we need to make them not required.

branches:
- master
paths:
- '**.cs'
- '**.csproj'
- '**.sln'
- '**.config'
- '**.json'

workflow_dispatch:
inputs:
repo:
description: 'Docker Hub org and repo name'
required: false
required: true
default: 'nethermindeth/nethermind'
tag:
description: 'Image tag'
required: false
required: true
default: ''
dockerfile:
description: 'Dockerfile to use'
required: false
required: true
default: 'Dockerfile'

env:
REPO: ${{ github.event.inputs.repo || 'nethermindeth/nethermind' }}
TAG: ${{ github.event.inputs.tag || 'master' }}
DOCKERFILE: ${{ github.event.inputs.dockerfile || 'Dockerfile' }}

jobs:
build-dockers:
Expand All @@ -23,32 +38,40 @@ jobs:
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Unshallow fetching
run: git fetch --unshallow

- name: Configure settings
id: settings
run: |
echo "BUILD_TIMESTAMP=$(date '+%s')" >> $GITHUB_OUTPUT
echo "COMMIT_HASH=$(git describe --always --exclude=* --abbrev=40)" >> $GITHUB_OUTPUT
echo "TAG_FROM_REPO=$(git describe --tags --always | cut -d- -f1)" >> $GITHUB_OUTPUT

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2

- name: Log in to Docker Hub
if: success()
run: |
echo "${{ secrets.DOCKER_ACCESS_TOKEN }}" | docker login --username "${{ secrets.DOCKER_USERNAME }}" --password-stdin

- name: Build and pushing image to Docker registry (major) / trigger DAppNode build
if: github.event.inputs.tag == steps.settings.outputs.TAG_FROM_REPO
if: env.TAG == steps.settings.outputs.TAG_FROM_REPO
run: |
docker buildx build --platform=linux/amd64,linux/arm64 -t "${{ github.event.inputs.repo }}:latest" -t "${{ github.event.inputs.repo }}:${{ github.event.inputs.tag }}" -f ${{ github.event.inputs.dockerfile }} --build-arg COMMIT_HASH=${{ steps.settings.outputs.COMMIT_HASH }} --build-arg BUILD_TIMESTAMP=${{ steps.settings.outputs.BUILD_TIMESTAMP}} . --push
curl -s -X POST -u "${{ secrets.REPOSITORY_DISPATCH_TOKEN }}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" -d '{"event_type":"dappnode","client_payload":{"tag":"${{ github.event.inputs.tag }}"}}' https://api.github.com/repos/$GITHUB_REPOSITORY/dispatches
- name: Build and push image to Docker registry (patch)
if: github.event.inputs.tag != steps.settings.outputs.TAG_FROM_REPO
docker buildx build --platform=linux/amd64,linux/arm64 -t "${{ env.REPO }}:latest" -t "${{ env.REPO }}:${{ env.TAG }}" -f ${{ env.DOCKERFILE }} --build-arg COMMIT_HASH=${{ steps.settings.outputs.COMMIT_HASH }} --build-arg BUILD_TIMESTAMP=${{ steps.settings.outputs.BUILD_TIMESTAMP}} . --push
curl -s -X POST -u "${{ secrets.REPOSITORY_DISPATCH_TOKEN }}" -H "Accept: application/vnd.github.everest-preview+json" -H "Content-Type: application/json" -d '{"event_type":"dappnode","client_payload":{"tag":"${{ env.TAG }}"}}' https://api.github.com/repos/$GITHUB_REPOSITORY/dispatches

- name: Build and push image to Docker registry (patch)
if: env.TAG != steps.settings.outputs.TAG_FROM_REPO
run: |
docker buildx build --platform=linux/amd64,linux/arm64 -t "${{ github.event.inputs.repo }}:${{ github.event.inputs.tag }}" -f ${{ github.event.inputs.dockerfile }} --build-arg COMMIT_HASH=${{ steps.settings.outputs.COMMIT_HASH }} --build-arg BUILD_TIMESTAMP=${{ steps.settings.outputs.BUILD_TIMESTAMP}} . --push
docker buildx build --platform=linux/amd64,linux/arm64 -t "${{ env.REPO }}:${{ env.TAG }}" -f ${{ env.DOCKERFILE }} --build-arg COMMIT_HASH=${{ steps.settings.outputs.COMMIT_HASH }} --build-arg BUILD_TIMESTAMP=${{ steps.settings.outputs.BUILD_TIMESTAMP}} . --push

- name: Clear Docker cache
if: always()
run: |
Expand Down