-
Notifications
You must be signed in to change notification settings - Fork 63
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
Showing
4 changed files
with
244 additions
and
40 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,79 @@ | ||
name: Deploy | ||
description: Build and push a docker image to Docker Hub | ||
|
||
outputs: | ||
tag: | ||
description: "Tags for the docker image" | ||
value: ${{ steps.meta.outputs.tags[0] }} | ||
|
||
inputs: | ||
platform: | ||
description: The platform to build for | ||
type: string | ||
required: true | ||
build_args: | ||
description: Build arguments to pass to the Docker build | ||
default: "" | ||
type: string | ||
required: false | ||
tag: | ||
description: Docker hub tag to push to | ||
type: string | ||
required: true | ||
# Secrets | ||
DOCKER_USERNAME: | ||
required: true | ||
DOCKER_PASSWORD: | ||
required: true | ||
MACOS_PASSWORD: | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Checkout this repo | ||
uses: actions/checkout@v4 | ||
- name: Set up Docker Context for Buildx | ||
shell: bash | ||
id: buildx-context | ||
run: | | ||
docker context use builders || docker context create builders | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
endpoint: builders | ||
- name: Unlock MacOS keychain for Docker Hub login | ||
shell: bash | ||
if: runner.os == 'macOS' | ||
run: | | ||
security -v unlock-keychain -p ${{ inputs.MACOS_PASSWORD }} ~/Library/Keychains/login.keychain-db | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ inputs.DOCKER_USERNAME }} | ||
password: ${{ inputs.DOCKER_PASSWORD }} | ||
- name: Generate slug | ||
id: vars | ||
shell: bash | ||
run: | | ||
echo "slug=$(echo '${{ inputs.platform }}' | tr '/' '-')" >> $GITHUB_OUTPUT | ||
echo "DEBUG" | ||
echo "${{ inputs.tag }}" | ||
- name: Docker build & push | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: '.' | ||
file: Dockerfile | ||
tags: ${{ inputs.tag }}-${{ steps.vars.outputs.slug }} | ||
push: true | ||
platforms: ${{ inputs.platform }} | ||
build-args: ${{ inputs.build_args }} | ||
- name: Image digest & tags | ||
shell: bash | ||
run: | | ||
cat << EOF | ||
digest: ${{ steps.docker_build.outputs.digest }} | ||
tags: | ||
${{ inputs.tag }}-${{ steps.vars.outputs.slug }} | ||
EOF |
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,73 @@ | ||
name: Manifest | ||
description: Build and push a docker manifest to Docker Hub | ||
|
||
inputs: | ||
platforms: | ||
# eg [{"platform":"linux/amd64", "runner": "ARM64", "slug": "something-arm64"},{"platform":"linux/arm64", "runner": "ubuntu-latest", "slug": "something-amd64"}] | ||
description: JSON list of platforms to build for | ||
type: string | ||
required: true | ||
tag: | ||
description: Docker hub tag to push to | ||
type: string | ||
required: true | ||
repository: | ||
description: Docker hub repository to push to | ||
type: string | ||
required: true | ||
DOCKER_USERNAME: | ||
required: true | ||
DOCKER_PASSWORD: | ||
required: true | ||
|
||
runs: | ||
using: composite | ||
steps: | ||
- name: Checkout this repo | ||
uses: actions/checkout@v4 | ||
- name: Generate images list | ||
id: generate_images_list | ||
shell: bash | ||
run: | | ||
PLATFORMS='${{ inputs.platforms }}' | ||
# Iterate over the platforms and build the image list | ||
len=$(echo $PLATFORMS | jq '. | length') | ||
for ((i=0; i<$len; i++)); do | ||
slug=$(echo $PLATFORMS | jq -r --argjson i $i '.[$i].slug') | ||
imagetag="${{ inputs.tag }}-$slug" | ||
imagetag=$(echo $imagetag | cut -d ':' -f2) | ||
image="${{ inputs.repository }}:$imagetag" | ||
url="https://hub.docker.com/v2/repositories/${{ inputs.repository }}/tags?page_size=25&page=1&ordering=&name=$imagetag" | ||
exists=$(curl -s $url | jq '.results | length > 0') | ||
if [ "$exists" == "true" ]; then | ||
IMAGES+="${{ inputs.tag }}-$slug " | ||
fi | ||
done | ||
IMAGES=${IMAGES::-1} # Remove the trailing space | ||
echo "IMAGES: $IMAGES" | ||
echo "images=$IMAGES" >> $GITHUB_OUTPUT | ||
- name: Check if there is atleast one image | ||
if: ${{ steps.generate_images_list.outputs.images == '[]' || steps.generate_images_list.outputs.images == '' }} | ||
shell: bash | ||
run: exit 1 | ||
- name: Set up Docker Context for Buildx | ||
shell: bash | ||
id: buildx-context | ||
run: | | ||
docker context create builders | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
endpoint: builders | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ inputs.DOCKER_USERNAME }} | ||
password: ${{ inputs.DOCKER_PASSWORD }} | ||
- name: Create and push manifest images | ||
shell: bash | ||
run: | | ||
docker buildx imagetools create --dry-run -t ${{ inputs.tag }} ${{ steps.generate_images_list.outputs.images }} | ||
docker buildx imagetools create -t ${{ inputs.tag }} ${{ steps.generate_images_list.outputs.images }} |
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,54 @@ | ||
name: 'Setup' | ||
description: 'Read and parse config files for builds' | ||
outputs: | ||
platforms: | ||
description: "Matrix of platforms and runner to use" | ||
value: ${{ steps.setup_platforms.outputs.platforms }} | ||
tag: | ||
description: "Tag for the docker image" | ||
value: ${{ steps.set_tag.outputs.tag }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
- uses: mikefarah/yq@v4.35.1 | ||
- name: Generate platform and runner matrix from config files | ||
id: setup_platforms | ||
shell: bash | ||
run: | | ||
PLATFORMS_JSON="[" | ||
# Extract the platforms | ||
platforms=$(yq e ".ethereum-genesis-generator[]" platforms.yaml) | ||
for platform in $platforms; do | ||
slug=$(echo "$platform" | tr '/' '-') | ||
runner=$(yq e ".\"$platform\"" runners.yaml) | ||
PLATFORMS_JSON+="{\"platform\":\"$platform\", \"runner\":\"$runner\", \"slug\":\"$slug\"}," | ||
done | ||
PLATFORMS_JSON="${PLATFORMS_JSON%,}]" | ||
echo "platforms=$PLATFORMS_JSON" >> $GITHUB_OUTPUT | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ethpandaops/ethereum-genesis-generator | ||
flavor: latest=auto | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=ref,event=pr | ||
type=ref,event=branch | ||
type=sha | ||
type=match,event=tag,pattern=^v\d+\.\d+\.\d+$,group=0 | ||
type=match,event=tag,pattern=^verkle-gen-v\d+\.\d+\.\d+$,group=0 | ||
type=match,event=tag,pattern=^ephemery-v\d+\.\d+\.\d+$,group=0 | ||
- name: Set tag | ||
id: set_tag | ||
shell: bash | ||
run: | | ||
echo "tag=${{ fromJSON(steps.meta.outputs.json).tags[0] }}" >> $GITHUB_OUTPUT | ||
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