Skip to content

Build and push disk images #12

Build and push disk images

Build and push disk images #12

Workflow file for this run

name: "Build and push bootc disk images"
on:
workflow_dispatch:
pull_request:
env:
REGISTRY: quay.io
REPOSITORY: flightctl
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
flavor: [rhel]
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install podman
run: sudo apt install podman
- name: Build and push disk images
run: |
mkdir output
URL=${{ env.REGISTRY }}/${{ env.REPOSITORY}}/flightctl-agent-${{ matrix.flavor }}
ARCHES="amd64 arm64"
FORMATS="qcow2 raw"
oras login -u "${{ secrets.QUAY_FLIGHTCTL_INFRA_ROBOT_USERNAME }}" -p "${{ secrets.QUAY_FLIGHTCTL_INFRA_ROBOT_PASSWORD }}" "${{ env.REGISTRY }}"
oras blob push $URL .github/workflow-scripts/empty.json
cp .github/workflow-scripts/index.json-head index.json
for ARCH in ARCHES; do
for FORMAT in FORMATS; do
sudo podman run --rm \
-it \
--privileged \
--pull=newer \
--security-opt label=type:unconfined_t \
-v $(pwd)/output:/output \
-v /var/lib/containers/storage:/var/lib/containers/storage \
quay.io/centos-bootc/bootc-image-builder:latest \
--type $FORMAT \
--target-arch $ARCH
"${{ env.REGISTRY }}//flightctl-agent-${{ matrix.flavor }}:bootstrap"
ARTIFACT=$ARCH.$FORMAT
if [ -f output/image/disk.raw ];
mv output/image/disk.raw $ARTIFACT
else
mv output/qcow2/disk.qcow2 $ARTIFACT
fi
oras blob push $URL $ARTIFACT
export SHA="sha256:"$(sha256sum $ARTIFACT | awk '{print $1}')
export SIZE=$(cat amd.txt | wc -c)
cat .github/workflow-scripts/manifest.json.tmpl | envsubst > manifest.json
oras manifest push $URL manifest.json
export SHA=$(sha256sum manifest.json | awk '{print $1}')
export SIZE=$(cat manifest.json | wc -c)
cat ./github/workflow-scripts/manifests.tmpl | envsubst >> index.json
done
done
echo ' ]' >> index.json
echo '}' >> index.json
oras manifest push $URL:latest index.json