Build NS8 disk images #1427
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 NS8 disk images | |
on: | |
workflow_run: | |
workflows: [core] | |
types: | |
- completed | |
workflow_dispatch: | |
jobs: | |
core-version: | |
if: ${{ github.event.workflow_run.conclusion == 'success' }} | |
runs-on: ubuntu-latest | |
outputs: | |
is_stable: ${{ steps.check.outputs.is_stable }} | |
steps: | |
- id: python-dep | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.9 | |
- id: check | |
run: | | |
pip install semver | |
check_core_version=$(cat <<EOF | |
import semver, sys | |
try: | |
print("false") if semver.VersionInfo.parse("${{ github.event.workflow_run.head_branch }}").prerelease else print ("true") | |
except ValueError: print("false") | |
EOF | |
) | |
echo is_stable=$(python3 -c "$check_core_version") >> $GITHUB_OUTPUT | |
build-images-qemu: | |
runs-on: [self-hosted] | |
permissions: | |
contents: write | |
strategy: | |
fail-fast: false | |
matrix: | |
source: | |
- qemu.rl | |
needs: | |
- core-version | |
env: | |
DO_SPACE_NAME: 'ns8' | |
DO_SPACE_REGION: 'ams3' | |
if: needs.core-version.outputs.is_stable == 'true' | |
steps: | |
- name: Setup `packer` | |
uses: hashicorp/setup-packer@main | |
- uses: actions/checkout@v4 | |
with: | |
repository: NethServer/ns8-images | |
- name: Run `packer init` | |
id: init | |
run: packer init . | |
- name: Run `packer build` | |
id: validate | |
run: packer build --only=${{ matrix.source }} . | |
- id: qcow2 | |
run: | | |
IMAGE_PATH=$(cat packer-manifest.json | jq -r .builds[0].files[0].name) | |
echo "path=${IMAGE_PATH}" >> "$GITHUB_OUTPUT" | |
- id: vmdk | |
name: Convert to VMDK | |
run: | | |
VMDK_PATH=$(echo ${{ steps.qcow2.outputs.path }} | sed -e 's/\.qcow2$/\.vmdk/') | |
qemu-img convert -f qcow2 -O vmdk ${{ steps.qcow2.outputs.path }} $VMDK_PATH | |
echo "path=${VMDK_PATH}" >> "$GITHUB_OUTPUT" | |
- id: checksum | |
name: Create checksum | |
run: | | |
cd $(dirname ${{ steps.qcow2.outputs.path }}) | |
sha256sum $(basename ${{ steps.qcow2.outputs.path }}) > ../CHECKSUM | |
sha256sum $(basename ${{ steps.vmdk.outputs.path }}) >> ../CHECKSUM | |
- name: Upload qcow2 NS8 image | |
uses: BetaHuhn/do-spaces-action@v2 | |
with: | |
access_key: ${{ secrets.DO_SPACE_ACCESS_KEY }} | |
secret_key: ${{ secrets.DO_SPACE_SECRET_KEY }} | |
space_name: ${{ env.DO_SPACE_NAME }} | |
space_region: ${{ env.DO_SPACE_REGION }} | |
source: ${{ steps.qcow2.outputs.path }} | |
out_dir: ns8-images | |
- name: Upload vmdk NS8 image | |
uses: BetaHuhn/do-spaces-action@v2 | |
with: | |
access_key: ${{ secrets.DO_SPACE_ACCESS_KEY }} | |
secret_key: ${{ secrets.DO_SPACE_SECRET_KEY }} | |
space_name: ${{ env.DO_SPACE_NAME }} | |
space_region: ${{ env.DO_SPACE_REGION }} | |
source: ${{ steps.vmdk.outputs.path }} | |
out_dir: ns8-images | |
- name: Upload checksum | |
uses: BetaHuhn/do-spaces-action@v2 | |
with: | |
access_key: ${{ secrets.DO_SPACE_ACCESS_KEY }} | |
secret_key: ${{ secrets.DO_SPACE_SECRET_KEY }} | |
space_name: ${{ env.DO_SPACE_NAME }} | |
space_region: ${{ env.DO_SPACE_REGION }} | |
source: CHECKSUM | |
out_dir: ns8-images |