brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.8 KiB · 595c3f8 Raw
96 lines · yaml
1name: Build Container2description: >-3  Build and test a container using the standard llvm naming scheme for containers.4 5inputs:6  tag:7    description: >-8      The tag to use for this container.9    required: false10  container-name:11    description: >-12      The name for the container.13    required: true14  dockerfile:15    description: >-16      Path to docker file.17    required: false18  target:19    description: >-20      The container target to build 'passed to podman via ---target option'21    required: false22  context:23    description: >-24      Path to context for the container build.25    required: false26  test-command:27    description: >-28      Test command to run to ensure the container is working correctly.29    required: false30 31runs:32  using: "composite"33  steps:34    # podman is not installed by default on the ARM64 images.35    - name: Install Podman36      if: runner.arch == 'ARM64'37      shell: bash38      run: |39        sudo apt-get install podman40 41    - name: Build Container42      shell: bash43      env:44        INPUT_TAG: ${{inputs.tag }}45        INPUT_CONTAINER_NAME: ${{ inputs.container-name }}46        INPUT_TARGET: ${{ inputs.target }}47        INPUT_DOCKERFILE: ${{ inputs.dockerfile }}48        INPUT_CONTEXT: ${{ inputs.context }}49      id: build50      run: |51        env52        tag="${INPUT_TAG:-$(git rev-parse --short=12 HEAD)}"53 54        case "$RUNNER_ARCH" in55          ARM64)56            container_arch="arm64v8"57            ;;58          *)59            container_arch="amd64"60            ;;61        esac62 63        container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/$container_arch/$INPUT_CONTAINER_NAME:$tag"64        container_filename="$(echo $container_name  | sed -e 's/\//-/g' -e 's/:/-/g').tar"65        if [ -n "$INPUT_TARGET" ]; then66          podman_options="$podman_options --target $INPUT_TARGET"67        fi68        if [ -n "$INPUT_DOCKERFILE" ]; then69          podman_options="$podman_options -f $INPUT_DOCKERFILE"70        fi71        podman_options="$podman_options ${INPUT_CONTEXT:-.}"72        echo "Podman Options: $podman_options"73 74        podman build -t $container_name $podman_options75 76        podman save $container_name > $container_filename77 78        echo "container-full-name=$container_name" >> $GITHUB_OUTPUT79 80    - name: Create container artifact81      uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.082      with:83        name: ${{ inputs.container-name }}-${{ runner.arch }}84        path: "*.tar"85        retention-days: 1486 87    - name: Test container88      shell: bash89      if: inputs.test-command90      env:91        INPUT_TEST_COMMAND: ${{ inputs.test-command }}92        CONTAINER_FULL_NAME: ${{ steps.build.outputs.container-full-name }}93      run: |94        podman run --pull=never --rm -it $CONTAINER_FULL_NAME /usr/bin/bash -x -c "$INPUT_TEST_COMMAND"95 96