From 34749c86275b4cd5e60e19f0da2379805eff5904 Mon Sep 17 00:00:00 2001 From: Jaro Habiger Date: Sat, 11 May 2019 16:12:44 +0200 Subject: [PATCH] [github] automatically build images of pr's --- .cirrus.yml | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index e6703a50..ee60efb3 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,11 +1,12 @@ docker_builder: only_if: $CIRRUS_TAG !=~ "nightly/.*" env: - TOKEN: ENCRYPTED[475dccbf786af8c4c8bcedfdf7c507e9686192569f3be0c1d4dff35c6b6b1e36fedc29d489c75a75af515c84bd3c34ac] + TOKEN: ENCRYPTED[4e4d80e944992ff037ce22e89b29a5151ef75bf44b133db67fb3cfb5ff1f3aaf7722bf86028957fc99a07edecfbe0962] + UPLOAD_KEY: ENCRYPTED[218507b6609fd0eb0cd00663c48a10082930967672efe5655b56118e4f515561f0bbc893dbb6a5a943d55f384ec1285c] matrix: DEVICE: beta DEVICE: micro - clone_script: > + clone_script: | if [[ -z "$CIRRUS_PR" ]]; then git clone --recursive --branch=$CIRRUS_BRANCH https://x-access-token:${CIRRUS_REPO_CLONE_TOKEN}@github.com/${CIRRUS_REPO_FULL_NAME}.git $CIRRUS_WORKING_DIR else @@ -15,10 +16,14 @@ docker_builder: git reset --hard $CIRRUS_CHANGE_IN_REPO make_script: ./makefiles/docker-make.sh DEVICE=$DEVICE test_script: ./makefiles/docker-make.sh DEVICE=$DEVICE test - release_script: > + release_script: | + # compress the image + [ -z $CIRRUS_PR ] || PR="-pr-$CIRRUS_PR" + FILE=axiom-$DEVICE$PR-$(git describe --always --abbrev=8).img.xz + xz -T $(nproc) build/axiom-$DEVICE.img + mv build/axiom-$DEVICE.img.xz build/$FILE + if [ $CIRRUS_BRANCH = 'master' ]; then - # compress the image - xz -T $(nproc) build/axiom-$DEVICE.img # get the github-release tool wget https://github.com/aktau/github-release/releases/download/v0.7.2/linux-amd64-github-release.tar.bz2 tar -xf linux-amd64-github-release.tar.bz2 @@ -32,7 +37,24 @@ docker_builder: - Only continue, if you know, what you are doing! \`\`\` " || true - ./bin/linux/amd64/github-release upload -u $CIRRUS_REPO_OWNER -r $CIRRUS_REPO_NAME -t "nightly/$(git describe --always --abbrev=8)" -s $TOKEN -n "axiom-$DEVICE-$(git describe --always --abbrev=8).img.xz" -f build/axiom-$DEVICE.img.xz + ./bin/linux/amd64/github-release upload -u $CIRRUS_REPO_OWNER -r $CIRRUS_REPO_NAME -t "nightly/$(git describe --always --abbrev=8)" -s $TOKEN -n "$FILE" -f build/$FILE else - echo "not on master branch; skipping deploy..." + echo "not creating a github release, because this is not a build for the master branch" fi + + echo "$UPLOAD_KEY" | tr -d '\r' > /tmp/storage_key + chmod 600 /tmp/storage_key + scp -oStrictHostKeyChecking=no -i /tmp/storage_key -P 22201 build/$FILE file_storage@vup.niemo.de:/data/file_storage/data + rm /tmp/storage_key + + echo "Download the image of this build at https://axiom-images.niemo.de/$FILE" + + if [ $DEVICE = 'beta' ]; then + if [[ ! -z "$CIRRUS_PR" ]]; then + wget https://github.com/cloudposse/github-commenter/releases/download/0.5.0/github-commenter_linux_amd64 + chmod a+x github-commenter_linux_amd64 + ./github-commenter_linux_amd64 -token $TOKEN -owner $CIRRUS_REPO_OWNER -repo $CIRRUS_REPO_NAME -type pr -number $CIRRUS_PR -comment "[//]: # (tracking-code: wasDinkDrybatghivSeerz8opDyajMoartEvbagyivwavdapGa) + + Download a build of the latest commit at https://axiom-images.niemo.de/$FILE " -delete-comment-regex "wasDinkDrybatghivSeerz8opDyajMoartEvbagyivwavdapGa" + fi + fi