Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
47 changes: 47 additions & 0 deletions .github/actions/build-and-push/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: 'Build and Push Docker Images'
description: 'Build and push Docker images to multiple registries'
inputs:
dockerfile:
description: 'Dockerfile path'
required: true
ghcr_image_name:
description: 'ghcr.io image name'
required: true
acr_image_name:
description: 'Aliyun ACR image name'
required: false
default: ''
aliyun_credentials:
description: 'JSON object containing Aliyun ACR credentials { "registry": string, "username": string, "password": string }'
required: false
default: '{}'
runs:
using: 'composite'
steps:
- name: Build and push to ghcr.io
shell: bash
run: |
echo "Building and pushing to ghcr.io: ${{ inputs.ghcr_image_name }}"
dockerfile_dir=$(dirname "${{ inputs.dockerfile }}")
docker buildx build --push \
--file "${{ inputs.dockerfile }}" \
--platform linux/amd64 \
--tag "${{ inputs.ghcr_image_name }}" \
"$dockerfile_dir"
- name: Build and push to Aliyun ACR
shell: bash
run: |
# Check if Aliyun credentials are provided
aliyun_credentials='${{ inputs.aliyun_credentials }}'
if [ "$aliyun_credentials" != "{}" ] && [ "$aliyun_credentials" != "" ] && [ "$aliyun_credentials" != "null" ] && [ "${{ inputs.acr_image_name }}" != "" ]; then
registry=$(echo "$aliyun_credentials" | jq -r '.registry')
if [ -n "$registry" ] && [ "$registry" != "null" ]; then
echo "Building and pushing to Aliyun ACR: ${{ inputs.acr_image_name }}"
dockerfile_dir=$(dirname "${{ inputs.dockerfile }}")
docker buildx build --push \
--file "${{ inputs.dockerfile }}" \
--platform linux/amd64 \
--tag "${{ inputs.acr_image_name }}" \
"$dockerfile_dir"
fi
fi
37 changes: 37 additions & 0 deletions .github/actions/build-cn-images/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'Build and Push CN Images'
description: 'Build and push CN (Chinese) versions of Docker images'
inputs:
dockerfile:
description: 'Dockerfile path'
required: true
ghcr_image_name:
description: 'ghcr.io CN image name'
required: true
acr_image_name:
description: 'Aliyun ACR CN image name'
required: false
default: ''
aliyun_credentials:
description: 'JSON object containing Aliyun ACR credentials { "registry": string, "username": string, "password": string }'
required: false
default: '{}'
runs:
using: 'composite'
steps:
- name: Build and push CN image to ghcr.io
shell: bash
run: |
echo "Building and pushing CN image to ghcr.io: ${{ inputs.ghcr_image_name }}"
./bin/runtimectl ci build "${{ inputs.dockerfile }}" "${{ inputs.ghcr_image_name }}" --cn --push | bash
- name: Build and push CN image to Aliyun ACR
shell: bash
run: |
# Check if Aliyun credentials are provided
aliyun_credentials='${{ inputs.aliyun_credentials }}'
if [ "$aliyun_credentials" != "{}" ] && [ "$aliyun_credentials" != "" ] && [ "$aliyun_credentials" != "null" ] && [ "${{ inputs.acr_image_name }}" != "" ]; then
registry=$(echo "$aliyun_credentials" | jq -r '.registry')
if [ -n "$registry" ] && [ "$registry" != "null" ]; then
echo "Building and pushing CN image to Aliyun ACR: ${{ inputs.acr_image_name }}"
./bin/runtimectl ci build "${{ inputs.dockerfile }}" "${{ inputs.acr_image_name }}" --cn --push | bash
fi
fi
130 changes: 130 additions & 0 deletions .github/actions/build-level/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
name: 'Build Level'
description: 'Build a specific dependency level with all packages in that level'
inputs:
level_index:
description: 'The dependency level index (0, 1, 2)'
required: true
level_packages:
description: 'JSON array of packages in this level'
required: true
tag:
description: 'Tag for the Docker image'
required: true
tag_cn:
description: 'CN tag for the Docker image'
required: true
github_token:
description: 'GitHub Token for ghcr.io login'
required: true
aliyun_credentials:
description: 'JSON object containing Aliyun ACR credentials { "registry": string, "username": string, "password": string }'
required: false
default: '{}'
previous_levels:
description: 'JSON array of previous levels that must be completed'
required: false
default: '[]'
runs:
using: 'composite'
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup bin/runtimectl
uses: ./.github/actions/setup-runtimectl
- name: Setup Docker
uses: ./.github/actions/setup-docker
- name: Docker Login
uses: ./.github/actions/docker-login
with:
github_token: ${{ inputs.github_token }}
aliyun_credentials: ${{ inputs.aliyun_credentials }}
- name: Build level packages
shell: bash
run: |
echo "Building Level ${{ inputs.level_index }}"

# Parse level packages
level_packages='${{ inputs.level_packages }}'

if [ "$level_packages" = "null" ] || [ -z "$level_packages" ] || [ "$level_packages" = "[]" ]; then
echo "No packages in level ${{ inputs.level_index }}, skipping..."
exit 0
fi

# Validate JSON and count packages in this level
if ! echo "$level_packages" | jq empty 2>/dev/null; then
echo "Invalid JSON in level_packages: $level_packages"
exit 1
fi

package_count=$(echo "$level_packages" | jq 'length // 0')
echo "Level ${{ inputs.level_index }} contains $package_count packages"

# Build each package in this level
echo "$level_packages" | jq -r '.[]? // empty' | while read -r build_target; do
if [ -n "$build_target" ]; then
echo "Building: $build_target"

# Validate build
./bin/runtimectl ci validate-build "$build_target"

# Update base image references
dependencies=$(./bin/runtimectl -o json ci analyze-dependencies | jq -r --arg path "$build_target" '.nodes[]? | select(.path == $path) | .dependencies // [] | .[]? // empty')

for dep in $dependencies; do
# Find the corresponding dockerfile for this dependency
dep_dockerfile=$(./bin/runtimectl -o json ci analyze-dependencies | jq -r --arg dep "$dep" '.nodes[]? | select(.name + "-" + .version == $dep) | .path // empty')

if [ -n "$dep_dockerfile" ]; then
# Generate the image name for the dependency
dep_image_name=$(./bin/runtimectl ci image-name "$dep_dockerfile" "ghcr.io" "${{ github.repository_owner }}" "${{ inputs.tag }}" | tr '[:upper:]' '[:lower:]')
echo "Updating dependency $dep to: $dep_image_name"
./bin/runtimectl ci update-base-image "$build_target" "$dep_image_name"
fi
done

# Generate image names
ghcr_image_name=$(./bin/runtimectl ci image-name "$build_target" "ghcr.io" "${{ github.repository_owner }}" "${{ inputs.tag }}" | tr '[:upper:]' '[:lower:]')
acr_image_name=$(./bin/runtimectl ci image-name "$build_target" "registry.cn-hangzhou.aliyuncs.com" "${{ github.repository_owner }}" "${{ inputs.tag }}" | tr '[:upper:]' '[:lower:]')

# Build and push images
echo "Building and pushing: $ghcr_image_name"
# Change to the directory containing the Dockerfile
dockerfile_dir=$(dirname "$build_target")
docker build -f "$build_target" -t "$ghcr_image_name" "$dockerfile_dir"
docker push "$ghcr_image_name"

# Check if Aliyun credentials are provided
aliyun_credentials='${{ inputs.aliyun_credentials }}'
if [ "$aliyun_credentials" != "{}" ] && [ "$aliyun_credentials" != "" ] && [ "$aliyun_credentials" != "null" ]; then
registry=$(echo "$aliyun_credentials" | jq -r '.registry')
if [ -n "$registry" ] && [ "$registry" != "null" ]; then
echo "Building and pushing CN image: $acr_image_name"
docker tag "$ghcr_image_name" "$acr_image_name"
docker push "$acr_image_name"
fi
fi

# Build CN version
ghcr_cn_image_name=$(./bin/runtimectl ci image-name "$build_target" "ghcr.io" "${{ github.repository_owner }}" "${{ inputs.tag_cn }}" | tr '[:upper:]' '[:lower:]')
acr_cn_image_name=$(./bin/runtimectl ci image-name "$build_target" "registry.cn-hangzhou.aliyuncs.com" "${{ github.repository_owner }}" "${{ inputs.tag_cn }}" | tr '[:upper:]' '[:lower:]')

echo "Building and pushing CN image: $ghcr_cn_image_name"
docker build -f "$build_target" -t "$ghcr_cn_image_name" .
docker push "$ghcr_cn_image_name"

# Check if Aliyun credentials are provided for CN image
if [ "$aliyun_credentials" != "{}" ] && [ "$aliyun_credentials" != "" ] && [ "$aliyun_credentials" != "null" ]; then
registry=$(echo "$aliyun_credentials" | jq -r '.registry')
if [ -n "$registry" ] && [ "$registry" != "null" ]; then
echo "Building and pushing CN ACR image: $acr_cn_image_name"
docker tag "$ghcr_cn_image_name" "$acr_cn_image_name"
docker push "$acr_cn_image_name"
fi
fi

echo "Completed building: $build_target"
fi
done
29 changes: 29 additions & 0 deletions .github/actions/docker-login/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: 'Docker Registry Login'
description: 'Login to Docker registries (ghcr.io and Aliyun ACR)'
inputs:
github_token:
description: 'GitHub Token for ghcr.io login'
required: true
aliyun_credentials:
description: 'JSON object containing Aliyun ACR credentials { "registry": string, "username": string, "password": string }'
required: false
default: '{}'
runs:
using: 'composite'
steps:
- name: Login to ghcr.io
shell: bash
run: echo "${{ inputs.github_token }}" | docker login ghcr.io -u "${{ github.repository_owner }}" --password-stdin
- name: Login to Aliyun ACR
shell: bash
if: inputs.aliyun_credentials != '{}' && inputs.aliyun_credentials != '' && inputs.aliyun_credentials != 'null'
run: |
registry=$(echo "${{ inputs.aliyun_credentials }}" | jq -r '.registry')
username=$(echo "${{ inputs.aliyun_credentials }}" | jq -r '.username')
password=$(echo "${{ inputs.aliyun_credentials }}" | jq -r '.password')
if [ -n "$registry" ] && [ -n "$username" ] && [ -n "$password" ]; then
echo "$password" | docker login "$registry" -u "$username" --password-stdin
else
echo "Error: Incomplete Aliyun credentials provided"
exit 1
fi
48 changes: 48 additions & 0 deletions .github/actions/generate-image-names/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: 'Generate Image Names'
description: 'Generate image names for both ghcr.io and Aliyun ACR'
inputs:
dockerfile:
description: 'Dockerfile path'
required: true
tag:
description: 'Image tag'
required: true
aliyun_credentials:
description: 'JSON object containing Aliyun ACR credentials { "registry": string, "username": string, "password": string }'
required: false
default: '{}'
outputs:
ghcr_image_name:
description: 'Generated ghcr.io image name'
value: ${{ steps.generate.outputs.ghcr_image_name }}
acr_image_name:
description: 'Generated Aliyun ACR image name'
value: ${{ steps.generate.outputs.acr_image_name }}
runs:
using: 'composite'
steps:
- name: Generate image names
id: generate
shell: bash
run: |
echo "dockerfile=${{ inputs.dockerfile }}"
echo "tag=${{ inputs.tag }}"

# Generate ghcr.io image name
ghcr_image_name=$(./bin/runtimectl ci image-name "${{ inputs.dockerfile }}" "ghcr.io" "${{ github.repository_owner }}" "${{ inputs.tag }}" | tr '[:upper:]' '[:lower:]')
echo "ghcr_image_name=$ghcr_image_name" >> $GITHUB_OUTPUT

# Generate Aliyun ACR image name if credentials are provided
aliyun_credentials='${{ inputs.aliyun_credentials }}'
if [ "$aliyun_credentials" != "{}" ] && [ "$aliyun_credentials" != "" ] && [ "$aliyun_credentials" != "null" ]; then
registry=$(echo "$aliyun_credentials" | jq -r '.registry')
username=$(echo "$aliyun_credentials" | jq -r '.username')
if [ -n "$registry" ] && [ "$registry" != "null" ] && [ -n "$username" ] && [ "$username" != "null" ]; then
acr_image_name=$(./bin/runtimectl ci image-name "${{ inputs.dockerfile }}" "$registry" "$username" "${{ inputs.tag }}" | tr '[:upper:]' '[:lower:]')
echo "acr_image_name=$acr_image_name" >> $GITHUB_OUTPUT
else
echo "acr_image_name=" >> $GITHUB_OUTPUT
fi
else
echo "acr_image_name=" >> $GITHUB_OUTPUT
fi
9 changes: 9 additions & 0 deletions .github/actions/setup-docker/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: 'Setup Docker Build Environment'
description: 'Setup Docker buildx and QEMU for multi-platform builds'
runs:
using: 'composite'
steps:
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
13 changes: 13 additions & 0 deletions .github/actions/setup-runtimectl/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: 'Setup Runtimectl'
description: 'Build and setup runtimectl binary'
runs:
using: 'composite'
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'
- name: Build runtimectl
shell: bash
run: |
make build
Loading