Skip to content

dockerhub

dockerhub #2

name: Build and Push to Docker Hub
on:
workflow_dispatch:
push:
branches:
- main
env:
DOCKERHUB_REPOSITORY: jinnuae40/story-geth
NETWORK: iliad
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: |
echo "COMMIT=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
echo "VERSION=$(date +%Y%m%d%H%M%S)" >> $GITHUB_ENV
echo "BUILDNUM=$GITHUB_RUN_NUMBER" >> $GITHUB_ENV
echo "REPOSITORY_URI=$DOCKERHUB_REPOSITORY" >> $GITHUB_ENV
echo "NETWORK=$NETWORK" >> $GITHUB_ENV
- uses: docker/setup-buildx-action@v2
- uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: ${{ runner.os }}-buildx-
- uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- run: |
docker buildx create --use
docker buildx build \
--platform linux/amd64,linux/arm64,linux/arm64/v8 \
--build-arg COMMIT=$COMMIT \
--build-arg VERSION=$VERSION \
--build-arg BUILDNUM=$BUILDNUM \
--build-arg NETWORK=$NETWORK \
-t $REPOSITORY_URI:latest \
-t $REPOSITORY_URI:$COMMIT \
-t $REPOSITORY_URI:$VERSION \
--cache-from=type=local,src=/tmp/.buildx-cache \
--cache-to=type=local,dest=/tmp/.buildx-cache \
--push \
-f ./Dockerfile \
.