Skip to content

Commit

Permalink
[github] automatically build images of pr's
Browse files Browse the repository at this point in the history
  • Loading branch information
anuejn authored and rroohhh committed May 15, 2019
1 parent c139a45 commit 34749c8
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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 [email protected]:/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

0 comments on commit 34749c8

Please sign in to comment.