|
| 1 | +--- |
| 2 | +name: Build disk images |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + inputs: |
| 7 | + upload-to-s3: |
| 8 | + description: "Upload to S3" |
| 9 | + required: false |
| 10 | + default: false |
| 11 | + type: boolean |
| 12 | + platform: |
| 13 | + required: true |
| 14 | + type: choice |
| 15 | + options: |
| 16 | + - amd64 |
| 17 | + - arm64 |
| 18 | + pull_request: |
| 19 | + branches: |
| 20 | + - main |
| 21 | + paths: |
| 22 | + - './disk_config/iso.toml' |
| 23 | + - './.github/workflows/build-disk.yml' |
| 24 | + |
| 25 | +env: |
| 26 | + IMAGE_NAME: ${{ github.event.repository.name }} # output of build.yml, keep in sync |
| 27 | + IMAGE_REGISTRY: "ghcr.io/${{ github.repository_owner }}" # do not edit |
| 28 | + DEFAULT_TAG: "latest" |
| 29 | + BIB_IMAGE: "ghcr.io/lorbuschris/bootc-image-builder:20250608" # "quay.io/centos-bootc/bootc-image-builder:latest" - see https://github.com/osbuild/bootc-image-builder/pull/954 |
| 30 | + |
| 31 | +concurrency: |
| 32 | + group: ${{ github.workflow }}-${{ github.ref || github.run_id }} |
| 33 | + cancel-in-progress: true |
| 34 | + |
| 35 | +jobs: |
| 36 | + build: |
| 37 | + name: Build disk images |
| 38 | + runs-on: ${{ inputs.platform == 'amd64' && 'ubuntu-24.04' || 'ubuntu-24.04-arm' }} |
| 39 | + strategy: |
| 40 | + fail-fast: false |
| 41 | + matrix: |
| 42 | + disk-type: ["qcow2", "anaconda-iso"] |
| 43 | + permissions: |
| 44 | + contents: read |
| 45 | + packages: read |
| 46 | + id-token: write |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Prepare environment |
| 50 | + run: | |
| 51 | + USER_UID=$(id -u) |
| 52 | + USER_GID=$(id -g) |
| 53 | + # Concatenate the types with a hyphen |
| 54 | + DISK_TYPE=$(echo "${{ matrix.disk-type }}" | tr ' ' '-') |
| 55 | + # Lowercase the image uri |
| 56 | + echo "IMAGE_REGISTRY=${IMAGE_REGISTRY,,}" >> ${GITHUB_ENV} |
| 57 | + echo "IMAGE_NAME=${IMAGE_NAME,,}" >> ${GITHUB_ENV} |
| 58 | + echo "DISK_TYPE=${DISK_TYPE}" >> ${GITHUB_ENV} |
| 59 | + echo "USER_UID=${USER_UID}" >> ${GITHUB_ENV} |
| 60 | + echo "USER_GID=${USER_GID}" >> ${GITHUB_ENV} |
| 61 | +
|
| 62 | + - name: Install dependencies |
| 63 | + if: inputs.platform == 'arm64' |
| 64 | + run: | |
| 65 | + set -x |
| 66 | + sudo apt update -y |
| 67 | + sudo apt install -y \ |
| 68 | + podman |
| 69 | +
|
| 70 | + - name: Maximize build space |
| 71 | + if: inputs.platform != 'arm64' |
| 72 | + uses: ublue-os/remove-unwanted-software@cc0becac701cf642c8f0a6613bbdaf5dc36b259e # v9 |
| 73 | + with: |
| 74 | + remove-codeql: true |
| 75 | + |
| 76 | + - name: Checkout |
| 77 | + uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5 |
| 78 | + |
| 79 | + - name: Build disk images |
| 80 | + id: build |
| 81 | + uses: osbuild/bootc-image-builder-action@main |
| 82 | + with: |
| 83 | + builder-image: ${{ env.BIB_IMAGE }} |
| 84 | + config-file: ${{ matrix.disk-type == 'anaconda-iso' && './disk_config/iso.toml' || './disk_config/disk.toml' }} |
| 85 | + image: ${{ env.IMAGE_REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.DEFAULT_TAG }} |
| 86 | + chown: ${{ env.USER_UID }}:${{ env.USER_GID }} |
| 87 | + types: ${{ matrix.disk-type }} |
| 88 | + additional-args: --use-librepo=True |
| 89 | + |
| 90 | + - name: Upload disk images and Checksum to Job Artifacts |
| 91 | + if: inputs.upload-to-s3 != true && github.event_name != 'pull_request' |
| 92 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 93 | + with: |
| 94 | + path: ${{ steps.build.outputs.output-directory }} |
| 95 | + if-no-files-found: error |
| 96 | + retention-days: 0 |
| 97 | + compression-level: 0 |
| 98 | + overwrite: true |
| 99 | + |
| 100 | + - name: Upload to S3 |
| 101 | + if: inputs.upload-to-s3 == true && github.event_name != 'pull_request' |
| 102 | + shell: bash |
| 103 | + env: |
| 104 | + RCLONE_CONFIG_S3_TYPE: s3 |
| 105 | + RCLONE_CONFIG_S3_PROVIDER: ${{ secrets.S3_PROVIDER }} |
| 106 | + RCLONE_CONFIG_S3_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }} |
| 107 | + RCLONE_CONFIG_S3_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }} |
| 108 | + RCLONE_CONFIG_S3_REGION: ${{ secrets.S3_REGION }} |
| 109 | + RCLONE_CONFIG_S3_ENDPOINT: ${{ secrets.S3_ENDPOINT }} |
| 110 | + SOURCE_DIR: ${{ steps.build.outputs.output-directory }} |
| 111 | + run: | |
| 112 | + sudo apt-get update |
| 113 | + sudo apt-get install -y rclone |
| 114 | + rclone copy $SOURCE_DIR S3:${{ secrets.S3_BUCKET_NAME }} |
0 commit comments