testing de push logic in travis other logic still incomplete

This commit is contained in:
thelamer 2019-11-18 18:28:31 -08:00
parent a01cda92ca
commit 3d44646175
5 changed files with 144 additions and 0 deletions

59
.travis.yml Normal file
View file

@ -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 "/*"

28
script/build_release Executable file
View file

@ -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 ..

16
script/index.html Normal file
View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Netboot.xyz BootLoaders</title>
</head>
<body>
<a href="ipxe/netboot.xyz.iso">netboot.xyz.iso</a>
<a href="ipxe/netboot.xyz-efi.iso">netboot.xyz-efi.iso</a>
<a href="ipxe/netboot.xyz.dsk">netboot.xyz.dsk</a>
<a href="ipxe/netboot.xyz.usb">netboot.xyz.usb</a>
<a href="ipxe/netboot.xyz.lkrn">netboot.xyz.lkrn</a>
<a href="ipxe/netboot.xyz.kpxe">netboot.xyz.kpxe</a>
<a href="ipxe/netboot.xyz-undionly.kpxe">netboot.xyz-undionly.kpxe</a>
<a href="ipxe/netboot.xyz.efi">netboot.xyz.efi</a>
</body>
</html>

36
script/message Executable file
View file

@ -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

5
script/pre_install Executable file
View file

@ -0,0 +1,5 @@
#!/bin/bash
# Install aws cli
pip install awscli tornado