-
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
229 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,78 @@ | ||
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: slzug | ||
shell: bash | ||
run: | | ||
echo "slug=$(echo "$platform" | tr '/' '-') | ||
- name: Docker build & push | ||
id: docker_build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: '.' | ||
file: Dockerfile | ||
tags: ${{ steps.meta.outputs.tags[0] }}-${{ steps.vars.outputs.slug }} | ||
push: true | ||
platforms: ${{ inputs.platform }} | ||
build-args: ${{ inputs.build_args }} | ||
- name: Image digest & tags | ||
shell: bash | ||
if: ${{ inputs.build_script == '' }} | ||
run: | | ||
cat << EOF | ||
digest: ${{ steps.docker_build.outputs.digest }} | ||
tags: | ||
${{ steps.meta.outputs.tags[0] }} | ||
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,72 @@ | ||
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" | ||
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.repository }}:${{ 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.repository }}:${{ inputs.tag }} ${{ steps.generate_images_list.outputs.images }} | ||
docker buildx imagetools create -t ${{ inputs.repository }}:${{ inputs.tag }} -t ${{ inputs.repository }}:${{ 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,43 @@ | ||
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: "Tags for the docker image" | ||
value: ${{ steps.meta.outputs.tags[0] }} | ||
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@v4 | ||
with: | ||
images: ethpandaops/ethereum-genesis-generator | ||
flavor: latest=true | ||
tags: | | ||
type=semver,pattern=verkle-gen-{{version}} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=semver,pattern={{version}} |
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