Skip to content

Commit

Permalink
fix(gh-actions): Make docker and release actions work
Browse files Browse the repository at this point in the history
  • Loading branch information
vponomaryov committed Feb 8, 2025
1 parent 926784d commit 88c11ce
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 44 deletions.
107 changes: 82 additions & 25 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@ on:
required: false
type: string
secrets:
DOCKERHUB_TOKEN:
DOCKERHUB_TOKEN_VP:
required: true
DOCKERHUB_USERNAME:
DOCKERHUB_USERNAME_VP:
required: true

workflow_dispatch:
inputs:
version:
Expand All @@ -21,37 +20,95 @@ on:
type: string

jobs:
docker:
runs-on: ubuntu-24.04
build-with-matrix:
name: Build ${{ matrix.build.platform }}
runs-on: ubuntu-24.04${{ matrix.build.platform == 'linux/arm64/v8' && '-arm' || '' }}
strategy:
matrix:
build:
- platform: linux/amd64
arch_short: amd
- platform: linux/arm64/v8
arch_short: arm
steps:
- name: Checkout
- name: Checkout Repository
uses: actions/checkout@v4
with:
fetch-depth: 0

# Needed for ARM64 Docker builds
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME_VP }}
password: ${{ secrets.DOCKERHUB_TOKEN_VP }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to dockerhub
- name: Enable BuildKit
run: echo "DOCKER_BUILDKIT=1" >> $GITHUB_ENV

- name: Build and Cache Image for the ${{ matrix.build.platform }} platform
run: |
docker buildx build \
-t scylladb/hydra-loaders \
--platform ${{ matrix.build.platform }} \
--provenance false \
--metadata-file metadata \
--output push-by-digest=true,type=image,push=true \
.
echo "Metadata file info:"
cat metadata
CURRENT_SHA=$(grep -oP '"containerimage.digest": *"\Ksha256:[a-f0-9]+' metadata)
echo CURRENT_SHA=$CURRENT_SHA
echo $CURRENT_SHA > digest-${{ matrix.build.arch_short }}
- name: Upload Digest Artifact
uses: actions/upload-artifact@v4
with:
name: digest-${{ matrix.build.arch_short }}
path: digest-${{ matrix.build.arch_short }}

push-after-matrix:
name: Push multiarch images
needs: build-with-matrix
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Log in to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push API
uses: docker/build-push-action@v6
username: ${{ secrets.DOCKERHUB_USERNAME_VP }}
password: ${{ secrets.DOCKERHUB_TOKEN_VP }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Enable BuildKit
run: echo "DOCKER_BUILDKIT=1" >> $GITHUB_ENV

- name: Download Digests
uses: actions/download-artifact@v4
with:
file: ./Dockerfile
context: .
push: true
pull: true
platforms: "linux/amd64,linux/arm64/v8"
target: production
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
scylladb/latte:latest
scylladb/latte:${{ inputs.version }}
path: digests

- name: Create Multi-Arch Manifest and Push
run: |
ls -Rl digests
SHA_AMD=$(cat digests/digest-amd/digest-amd)
SHA_ARM=$(cat digests/digest-arm/digest-arm)
echo SHA_AMD=$SHA_AMD
echo SHA_ARM=$SHA_ARM
docker manifest create scylladb/hydra-loaders:latte-${{ inputs.version }} \
--amend scylladb/hydra-loaders@$SHA_AMD \
--amend scylladb/hydra-loaders@$SHA_ARM
docker manifest push scylladb/hydra-loaders:latte-${{ inputs.version }}
docker manifest inspect scylladb/hydra-loaders:latte-${{ inputs.version }}
docker manifest create scylladb/hydra-loaders:latte-latest \
--amend scylladb/hydra-loaders@$SHA_AMD \
--amend scylladb/hydra-loaders@$SHA_ARM
docker manifest push scylladb/hydra-loaders:latte-latest
docker manifest inspect scylladb/hydra-loaders:latte-latest
6 changes: 3 additions & 3 deletions .github/workflows/dockerhub-description.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ jobs:
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: scylladb/latte
username: ${{ secrets.DOCKERHUB_USERNAME_VP }}
password: ${{ secrets.DOCKERHUB_TOKEN_VP }}
repository: vponomarovatscylladb/hydra-loaders
short-description: ${{ github.event.repository.description }}
enable-url-completion: true
51 changes: 35 additions & 16 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ on:
push:
tags:
- '*'
branches:
- 0.28.2-scylladb

jobs:
get_tag:
runs-on: ubuntu-latest
outputs:
tag: ${{ steps.version_tag.outputs.tag }}
# tag: ${{ steps.version_tag.outputs.tag }}
tag: "0.28.2-scylladb"
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -19,20 +23,40 @@ jobs:
with:
tagRegex: "(.*)"

release:
name: Create release based on tag if not exists
runs-on: ubuntu-24.04
steps:
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ github.ref_name }}
run: |
set +e
if [[ "$(gh release view $tag 2>&1)" == "release not found" ]]; then
echo "Release '$tag' not found. Creating..."
gh release create "$tag" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} ${tag#}" \
--generate-notes
else
echo "Release '$tag' found. Skipping this step..."
fi
docker_build:
uses: ./.github/workflows/docker.yml
needs: [get_tag]
with:
version: ${{ needs.get_tag.outputs.tag }}
secrets:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
DOCKERHUB_USERNAME_VP: ${{ secrets.DOCKERHUB_USERNAME_VP }}
DOCKERHUB_TOKEN_VP: ${{ secrets.DOCKERHUB_TOKEN_VP }}

release:
release-artifacts:
needs: [get_tag, docker_build]
strategy:
matrix:
os: [ubuntu-22.04, ubuntu-24.04]
os: [ubuntu-22.04, ubuntu-24.04, ubuntu-24.04-arm]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
Expand All @@ -45,24 +69,19 @@ jobs:
command: build
args: --release

- name: Create Release
id: create_release
uses: actions/create-release@v1
- name: Get release
id: get_release
uses: bruceadams/get-release@v1.3.2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ needs.get_tag.outputs.tag }}
release_name: Release ${{ github.ref }}
draft: false
prerelease: false
GITHUB_TOKEN: ${{ github.token }}

- name: Upload Release Asset
id: upload-release-asset-unix
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
upload_url: ${{ steps.get_release.outputs.upload_url }}
asset_path: ./target/release/latte
asset_name: latte-${{ matrix.os }}
asset_name: latte-${{ needs.get_tag.outputs.tag }}--${{ matrix.os }}
asset_content_type: application/octet-stream

0 comments on commit 88c11ce

Please sign in to comment.