Build and push disk images #10
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: "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" | |
echo "${{ secrets.QUAY_FLIGHTCTL_INFRA_ROBOT_USERNAME}}" | oras login -u "${{ secrets.QUAY_FLIGHTCTL_INFRA_ROBOT_USERNAME }}" --password-stdin "${{ env.REGISTRY }}" | |
oras blob push $URL .github/workflow-scripts/empty.json | |
cp .github/workflow-scripts/index.json 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 |