Skip to content

Merge pull request #124 from spidernet-io/pr/welan/verison #3

Merge pull request #124 from spidernet-io/pr/welan/verison

Merge pull request #124 from spidernet-io/pr/welan/verison #3

name: Release Mx-Rdma Tools
env:
CHART_PATH: mx-rdma-tools/chart
DOCKERFILE_PATH: mx-rdma-tools/image
IMAGE_NAME: mx-rdma-tools
BUILD_PLATFORM: linux/amd64
GEN_DOCKERFILE_SCRIPT: mx-rdma-tools/image/generateDockerfile.sh
CODE_SHA: ''
on:
workflow_dispatch:
inputs:
ref:
description: 'compile the chart based on the sha or branch of code'
required: true
default: main
push:
tags:
- mx-rdma-tools-v[0-9]+.[0-9]+.[0-9]+
permissions: write-all
jobs:
get_info:
runs-on: ubuntu-latest
outputs:
chart_path: ${{ env.CHART_PATH }}
code_sha: ${{ env.CODE_SHA }}
dockerfile_dirctory: ${{ env.DOCKERFILE_PATH }}
generateDockerfileScript: ${{ env.GEN_DOCKERFILE_SCRIPT }}
image_name: ${{ env.IMAGE_NAME }}
build_platform: ${{ env.BUILD_PLATFORM }}
image_tag: ${{ steps.generate_dockerfile.outputs.image_tag }}
steps:
- name: Get information
id: get_original_ref
run: |
echo '${{ toJSON(github) }}'
if ${{ github.event_name == 'workflow_dispatch' }}; then
echo "call by workflow_dispatch"
echo "CODE_SHA=${{ github.event.inputs.ref }}" >> $GITHUB_ENV
elif ${{ github.event_name == 'push' }} ; then
echo "call by push tag"
echo "CODE_SHA=${GITHUB_REF##*/}" >> $GITHUB_ENV
else
exit 1
fi
- name: Checkout Source Code
uses: actions/checkout@v4
with:
persist-credentials: false
ref: ${{ steps.get_original_ref.outputs.code_sha }}
- name: Generate Dockerfile
id: generate_dockerfile
run: |
set -x
cd ${{ env.DOCKERFILE_PATH }}
chmod +x ./generateDockerfile.sh
source ./generateDockerfile.sh
# image_tag from current tag
image_tag=$(grep -Eo 'v[0-9]+.[0-9]+.[0-9]+' <<< "${{ env.CODE_SHA }}")
[ -n "${image_tag}" ] || { echo "error, failed to get image_tag from commit id"; exit 1 ; }
echo "image_tag=${image_tag}" >> $GITHUB_OUTPUT
call-image-workflow:
needs: [get_info]
uses: ./.github/workflows/callBuildImage.yaml
with:
code_sha: ${{ needs.get_info.outputs.code_sha }}
push_image: true
image_name: ${{ needs.get_info.outputs.image_name }}
dockerfile_dirctory: ${{ needs.get_info.outputs.dockerfile_dirctory }}
build_platform: ${{ needs.get_info.outputs.build_platform }}
upload_artifact: false
image_tag: ${{ needs.get_info.outputs.image_tag }}
generateDockerfileScript: ${{ needs.get_info.outputs.generateDockerfileScript }}
secrets: inherit
call-chart-workflow:
needs: [get_info,call-image-workflow]
uses: ./.github/workflows/callBuildChart.yaml
with:
code_sha: ${{ needs.get_info.outputs.code_sha }}
chart_path: ${{ needs.get_info.outputs.chart_path }}
secrets: inherit