Image Rdma Tools #18
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: Image Rdma Tools | |
env: | |
IMAGE_NAME: rdma-tools | |
DOCKERFILE_PATH: rdma-tools/image | |
on: | |
push: | |
branches: | |
- 'main' | |
paths: | |
- rdma-tools/image/** | |
pull_request_target: | |
types: | |
- opened | |
- synchronize | |
- reopened | |
paths: | |
# can not use env here | |
- rdma-tools/image/** | |
workflow_dispatch: | |
inputs: | |
ref: | |
description: 'sha, branch or tag for code' | |
required: true | |
default: main | |
permissions: write-all | |
jobs: | |
get_info: | |
runs-on: ubuntu-latest | |
outputs: | |
code_sha: ${{ env.code_sha }} | |
push_image: ${{ env.push_image }} | |
image_name: ${{ env.image_name }} | |
build_platform: ${{ env.build_platform }} | |
upload_artifact: ${{ env.upload_artifact }} | |
dockerfile_dirctory: ${{ env.dockerfile_dirctory }} | |
steps: | |
- name: get information | |
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 | |
echo "push_image=true" >> $GITHUB_ENV | |
echo "image_name=${{ env.IMAGE_NAME }}" >> $GITHUB_ENV | |
echo "dockerfile_dirctory=${{ env.DOCKERFILE_PATH }}" >> $GITHUB_ENV | |
echo "build_platform=linux/amd64,linux/arm64" >> $GITHUB_ENV | |
echo "upload_artifact=false" >> $GITHUB_ENV | |
elif ${{ github.event_name == 'push' }} ; then | |
echo "call by push tag" | |
echo "code_sha=${GITHUB_REF##*/}" >> $GITHUB_ENV | |
echo "push_image=true" >> $GITHUB_ENV | |
echo "image_name=${{ env.IMAGE_NAME }}" >> $GITHUB_ENV | |
echo "dockerfile_dirctory=${{ env.DOCKERFILE_PATH }}" >> $GITHUB_ENV | |
echo "build_platform=linux/amd64,linux/arm64" >> $GITHUB_ENV | |
echo "upload_artifact=false" >> $GITHUB_ENV | |
else | |
echo "call by PR" | |
echo "use sha ${{ github.event.pull_request.head.sha }} , by pr" | |
echo "code_sha=${{ github.event.pull_request.head.sha }}" >> $GITHUB_ENV | |
echo "push_image=false" >> $GITHUB_ENV | |
echo "image_name=${{ env.IMAGE_NAME }}" >> $GITHUB_ENV | |
echo "dockerfile_dirctory=${{ env.DOCKERFILE_PATH }}" >> $GITHUB_ENV | |
echo "build_platform=linux/amd64" >> $GITHUB_ENV | |
echo "upload_artifact=false" >> $GITHUB_ENV | |
fi | |
call-workflow: | |
needs: [get_info] | |
uses: ./.github/workflows/callBuildImage.yaml | |
with: | |
code_sha: ${{ needs.get_info.outputs.code_sha }} | |
push_image: ${{ needs.get_info.outputs.push_image }} | |
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: ${{ needs.get_info.outputs.upload_artifact }} | |
# leave image_tag empty , use commit id for tag | |
secrets: inherit |