-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0fc2a95
commit b04db10
Showing
1 changed file
with
132 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
name: Build docker image | ||
|
||
on: | ||
push: | ||
tags: | ||
- "v*" | ||
branches: | ||
- "develop" | ||
|
||
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.18.x] | ||
|
||
outputs: | ||
tags: ${{ steps.meta.outputs.tags }} | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
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: Build | ||
run: go build -v -ldflags "-X main.Version=${{ github.event.ref }} -X main.Commit=${{ github.sha }}" -o ./sfeth ./cmd/sfeth | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
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@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | ||
with: | ||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | ||
tags: | | ||
type=ref,event=tag | ||
type=sha,prefix=,enable=${{ github.ref == 'refs/heads/develop' }} | ||
flavor: latest=${{ startsWith(github.ref, 'refs/tags/') }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | ||
with: | ||
context: . | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
|
||
bundle-docker-versions: | ||
needs: build-vanilla | ||
runs-on: ubuntu-20.04 | ||
|
||
permissions: | ||
contents: read | ||
packages: write | ||
|
||
outputs: | ||
geth: ${{ steps.print.outputs.geth }} | ||
bsc: ${{ steps.print.outputs.bsc }} | ||
polygon: ${{ steps.print.outputs.polygon }} | ||
|
||
strategy: | ||
matrix: | ||
binary: [geth, bsc, polygon] | ||
steps: | ||
- name: Log in to the Container registry | ||
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9 | ||
with: | ||
registry: ${{ env.REGISTRY }} | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- run: | | ||
docker pull ghcr.io/streamingfast/go-ethereum:${{ matrix.binary }}-latest | ||
echo VERSION=$(docker inspect --format='{{index .Config.Labels "org.opencontainers.image.version"}}' 'ghcr.io/streamingfast/go-ethereum':${{ matrix.binary }}-latest) >> $GITHUB_ENV | ||
- name: Generate docker tags/labels from github build context | ||
id: meta | ||
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38 | ||
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=${{ github.ref == 'refs/heads/develop' }} | ||
type=sha,prefix=,suffix=-${{ matrix.binary }},enable=${{ github.ref == 'refs/heads/develop' }} | ||
flavor: latest=false | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc | ||
with: | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
file: ./Dockerfile.bundle | ||
build-args: | | ||
CHAIN_VERSION: ${{ env.VERSION }} | ||
SF_VERSION: ${{ needs.build-vanilla.outputs.tags[0] }} | ||
- id: print | ||
run: echo "::set-output name=${{ matrix.binary }}::${{ join(steps.meta.outputs.tags, ' ') }}" | ||
|
||
|
||
slack-notifications: | ||
needs: [build-vanilla, bundle-docker-versions] | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Slack notification | ||
env: | ||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} | ||
uses: Ilshidur/action-slack@2.0.2 | ||
with: | ||
args: | | ||
:done: *${{ 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 }}``` |