From 3d44646175ffee4e285492b815dd27b6b5d16ee5 Mon Sep 17 00:00:00 2001 From: thelamer Date: Mon, 18 Nov 2019 18:28:31 -0800 Subject: [PATCH] testing de push logic in travis other logic still incomplete --- .travis.yml | 59 ++++++++++++++++++++++++++++++++++++++++++++ script/build_release | 28 +++++++++++++++++++++ script/index.html | 16 ++++++++++++ script/message | 36 +++++++++++++++++++++++++++ script/pre_install | 5 ++++ 5 files changed, 144 insertions(+) create mode 100644 .travis.yml create mode 100755 script/build_release create mode 100644 script/index.html create mode 100755 script/message create mode 100755 script/pre_install diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..4f699a18 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,59 @@ +sudo: true + +language: bash + +services: + - docker + +env: + global: + - DEBIAN_FRONTEND="noninteractive" + +jobs: + include: + - stage: development + if: branch = development AND tag IS blank AND type != pull_request + before_install: + - ./script/pre_install + script: + - ./script/build_release dev + after_failure: + - ./script/message failure + deploy: + - provider: s3 + access_key_id: $AWS_ACCESS_KEY_ID + secret_access_key: $AWS_SECRET_ACCESS_KEY + bucket: $BUCKET_DEV + local_dir: s3out + upload-dir: $TRAVIS_COMMIT + region: us-west-2 + skip_cleanup: true + after_deploy: + - ./script/message dev-push + - stage: pull-request + if: type = pull_request + script: + - echo test + - stage: release-canidate + if: branch = development AND tag IS present AND type != pull_request + script: + - echo test + - stage: release + if: branch = master AND type != pull_request + script: + - echo test + deploy: + - provider: s3 + access_key_id: $AWS_ACCESS_KEY_ID + secret_access_key: $AWS_SECRET_ACCESS_KEY + bucket: $BUCKET_LIVE + local_dir: s3out + skip_cleanup: true + - provider: releases + api_key: $GITHUB_TOKEN + file_glob: true + file: githubout/* + skip_cleanup: true + after_deploy: + - aws configure set preview.cloudfront true + - aws cloudfront create-invalidation --distribution-id $CLOUDFRONT_DIST_ID_BOOT --paths "/*" diff --git a/script/build_release b/script/build_release new file mode 100755 index 00000000..af33e537 --- /dev/null +++ b/script/build_release @@ -0,0 +1,28 @@ +#!/bin/bash + +TYPE=$1 + +# Set boot domain +if [[ "${TYPE}" == "dev" ]]; then + BOOT_DOMAIN="${BUCKET_DEV}.s3-us-west-2.amazonaws.com/${TRAVIS_COMMIT}" +fi +sed -i \ + "/^#boot_domain/c\boot_domain: ${BOOT_DOMAIN}" \ + user_overrides.yml + +# Build release +docker build -t localbuild -f Dockerfile-build . +docker run --rm -it -v $(pwd):/buildout localbuild + +# Generate folder outputs +mkdir -p s3out +cp -r buildout/* s3out/ +cp script/index.html s3out/ +mkdir -p githubout +mv buildout/ipxe/* githubout/ +cd buildout +rm -Rf ipxe +tar -czf menus.tar.gz * +mv menus.tar.gz ../githubout +cd .. + diff --git a/script/index.html b/script/index.html new file mode 100644 index 00000000..f03dad40 --- /dev/null +++ b/script/index.html @@ -0,0 +1,16 @@ + + + + Netboot.xyz BootLoaders + + + netboot.xyz.iso + netboot.xyz-efi.iso + netboot.xyz.dsk + netboot.xyz.usb + netboot.xyz.lkrn + netboot.xyz.kpxe + netboot.xyz-undionly.kpxe + netboot.xyz.efi + + diff --git a/script/message b/script/message new file mode 100755 index 00000000..e3abeae8 --- /dev/null +++ b/script/message @@ -0,0 +1,36 @@ +#!/bin/bash + +TYPE=$1 + +if [ "${TYPE}" == "dev-push" ]; then + BOOT_URL="https://${BUCKET_DEV}.s3-us-west-2.amazonaws.com/${TRAVIS_COMMIT}/index.html" +fi + +# send status to discord +if [ "${TYPE}" == "failure" ]; then + curl -X POST --data \ + '{ + "avatar_url": "https://avatars.io/twitter/travisci", + "embeds": [ + { + "color": 16711680, + "description": "__**Failed to Build**__ \n**Build:** '${TRAVIS_BUILD_WEB_URL}'\n**External Version:** '${EXTERNAL_VERSION}'\n**Status:** Failure\n**Change:** https://github.com/netbootxyz/netboot.xyz/commit/'${TRAVIS_COMMIT}'\n" + } + ], + "username": "Travis CI" + }' \ + ${DISCORD_HOOK_URL} +else + curl -X POST --data \ + '{ + "avatar_url": "https://avatars.io/twitter/travisci", + "embeds": [ + { + "color": 1681177, + "description": "__**Boot Menu Published**__ \n**Files:** '${BOOT_URL}' \n**Build:** '${TRAVIS_BUILD_WEB_URL}'\n**External Version:** '${EXTERNAL_VERSION}'\n**Change:** https://github.com/netbootxyz/netboot.xyz/commit/'${TRAVIS_COMMIT}'\n" + } + ], + "username": "Travis CI" + }' \ + ${DISCORD_HOOK_URL} +fi diff --git a/script/pre_install b/script/pre_install new file mode 100755 index 00000000..d06455b6 --- /dev/null +++ b/script/pre_install @@ -0,0 +1,5 @@ +#!/bin/bash + +# Install aws cli + +pip install awscli tornado