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
name: ci | ||
on: | ||
push: | ||
branches: | ||
- "develop" | ||
- "master" | ||
- "release" | ||
- "docker_image_build" | ||
env: | ||
REGISTRY_IMAGE: legleux/test_rippled_image | ||
jobs: | ||
build: | ||
runs-on: [self-hosted, ${{ matrix.platform }}] | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
platform: | ||
- amd64 | ||
- arm64 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Set tags | ||
id: tag_name | ||
shell: bash | ||
run: | | ||
IMAGE_NAME="rippled" | ||
LATEST_BRANCH="master" | ||
SHA=${GITHUB_SHA::7} | ||
BASE_IMAGE_NAME=${IMAGE_NAME}:${SHA} | ||
echo "BASE_IMAGE_NAME=${BASE_IMAGE_NAME}" >> $GITHUB_OUTPUT | ||
BRANCH=${GITHUB_REF#refs/heads/} | ||
DH_TAGS="${SHA} ${BRANCH}" | ||
GH_TAGS="${SHA} ${BRANCH}" | ||
DH_IMAGE_NAME=${DOCKERHUB_REPO}/${IMAGE_NAME} | ||
echo "DH_IMAGE_NAME=${DH_IMAGE_NAME}" >> $GITHUB_OUTPUT | ||
GH_IMAGE_NAME="ghcr.io/${{ github.repository_owner }}/${IMAGE_NAME}" | ||
echo "GH_IMAGE_NAME=${GH_IMAGE_NAME}" >> $GITHUB_OUTPUT | ||
if [[ $BRANCH == ${LATEST_BRANCH} ]]; then | ||
echo "Tagging $BRANCH as 'latest'" | ||
DH_TAGS+=" latest" | ||
GH_TAGS+=" latest" | ||
fi | ||
echo "DH_TAGS=${DH_TAGS}" >> $GITHUB_OUTPUT | ||
echo "GH_TAGS=${GH_TAGS}" >> $GITHUB_OUTPUT | ||
echo "DH_TAGS: $DH_TAGS" | ||
echo "GH_TAGS: $GH_TAGS" | ||
- name: Get rippled version | ||
run: "find . -name find_version.py" | ||
- name: rippled version | ||
id: ripd_version | ||
run: | | ||
echo "rippled_version=$(python docker/small/find_version.py src/ripple/protocol/impl/BuildInfo.cpp | tail -n1)" >> $GITHUB_OUTPUT | ||
echo $(python docker/small/find_version.py src/ripple/protocol/impl/BuildInfo.cpp) | ||
echo "rippled version: $rippled_version" | ||
- name: Prepare | ||
run: | | ||
platform=${{ matrix.platform }} | ||
echo "PLATFORM_PAIR=linux/${platform//\//-}" >> $GITHUB_ENV | ||
- name: Show rippled version | ||
run: | | ||
echo "I got the version as: ${{ steps.ripd_version.outputs.rippled_version }}" | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
name=legleux/test_image,enable=true | ||
tags: | | ||
type=raw,value=multi-arch-github-action-build | ||
type=raw,value=latest | ||
type=raw,value=${{ github.head_ref || github.ref_name }} | ||
type=raw,value=${{ github.sha }} | ||
type=ref,event=branch | ||
type=ref,event=pr | ||
type=sha | ||
type=raw,value=${{ steps.ripd_version.outputs.rippled_version }} | ||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
with: | ||
buildkitd-flags: --debug | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: "legleux" | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Build and push by digest | ||
id: build | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: docker/small | ||
push: ${{ github.event_name == 'push' }} | ||
platforms: ${{ matrix.platform }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
# tags: ${{ steps.meta.outputs.tags }} | ||
outputs: type=image,name=legleux/test_image,push-by-digest=true,push=true | ||
- name: Show digest | ||
run: | | ||
echo "DOCKER_METADATA_OUTPUT_TAGS: $DOCKER_METADATA_OUTPUT_TAGS" | ||
echo "supposed output: ${{ steps.meta.outputs.tags }}" | ||
echo "It's lying: ${{env.DOCKER_METADATA_OUTPUT_TAGS}}" | ||
digest="${{ steps.build.outputs.digest }}" | ||
echo "What the hell is the digest" | ||
echo "${digest}" | ||
- name: Export digest | ||
run: | | ||
mkdir -p /tmp/digests | ||
digest="${{ steps.build.outputs.digest }}" | ||
touch "/tmp/digests/${digest#sha256:}" | ||
- name: Upload digest | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: digests-${{ env.PLATFORM_PAIR }} | ||
path: /tmp/digests/* | ||
if-no-files-found: error | ||
retention-days: 1 | ||
merge: | ||
runs-on: ubuntu-latest | ||
needs: | ||
- build | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: Download digests | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: /tmp/digests | ||
pattern: digests-* | ||
merge-multiple: true | ||
- name: rippled version | ||
id: ripd_version | ||
run: | | ||
echo "rippled_version=$(python docker/small/find_version.py src/ripple/protocol/impl/BuildInfo.cpp | tail -n1)" >> $GITHUB_OUTPUT | ||
echo $(python docker/small/find_version.py src/ripple/protocol/impl/BuildInfo.cpp) | ||
echo "rippled version: $rippled_version" | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ${{ env.REGISTRY_IMAGE }} | ||
tags: | | ||
type=raw,value=${{ github.sha }} | ||
type=sha,prefix= | ||
type=raw,value=${{ steps.ripd_version.outputs.rippled_version }} | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: "legleux" | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Create manifest list and push | ||
working-directory: /tmp/digests | ||
run: | | ||
echo "DOCKER_METADATA_OUTPUT_TAGS $DOCKER_METADATA_OUTPUT_TAGS" | ||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \ | ||
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *) | ||
- name: Inspect image | ||
run: | | ||
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }} |