From 496e8648d330f35b74fff384cc34bbb92cd60f0e Mon Sep 17 00:00:00 2001 From: Kasra Bigdeli Date: Sat, 19 Oct 2024 14:21:15 -0700 Subject: [PATCH] Testing build --- .github/workflows/test_workflow.yml | 32 ++++++++++++++ test_build.sh | 65 +++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) create mode 100644 .github/workflows/test_workflow.yml create mode 100644 test_build.sh diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml new file mode 100644 index 0000000..7cb074d --- /dev/null +++ b/.github/workflows/test_workflow.yml @@ -0,0 +1,32 @@ +name: Test Node multi-arch +on: + push: + branches: + - master +jobs: + run-pre-checks: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + - run: | + sudo bash -c "mkdir /captain && chown -R `whoami` /captain" + npm ci + npm run build + npm run lint + npm run formatter + npm run test + build-publish-docker-hub: + needs: run-pre-checks + runs-on: ubuntu-latest + steps: + - uses: azure/docker-login@v1 + with: + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + - uses: actions/checkout@v1 + - name: Build and Push Edge to DockerHub + shell: bash + run: ./test_build.sh diff --git a/test_build.sh b/test_build.sh new file mode 100644 index 0000000..1dc61c5 --- /dev/null +++ b/test_build.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# Exit early if any command fails +set -e + +# Print all commands +set -x + +pwd + +# ensure you're not running it on local machine +if [ -z "$CI" ] || [ -z "$GITHUB_REF" ]; then + echo "Running on a local machine! Exiting!" + exit 127 +else + echo "Running on CI" +fi + +CAPROVER_VERSION=0.0.1 +IMAGE_NAME=caprover/caprover-edge + +if [ ! -f ./package-lock.json ]; then + echo "package-lock.json not found!" + exit 1 +fi + +# BRANCH=$(git rev-parse --abbrev-ref HEAD) +# On Github the line above does not work, instead: +BRANCH=${GITHUB_REF##*/} +echo "on branch $BRANCH" +if [[ "$BRANCH" != "master" ]]; then + echo 'Not on master branch! Aborting script!' + exit 1 +fi + +## Building frontend app +ORIG_DIR=$(pwd) +FRONTEND_DIR=/home/runner/app-frontend +curl -Iv https://registry.yarnpkg.com/ +mkdir -p $FRONTEND_DIR && cd $FRONTEND_DIR +git clone https://github.com/githubsaturn/caprover-frontend.git +cd caprover-frontend +git log --max-count=1 +yarn install --no-cache --frozen-lockfile --network-timeout 600000 +echo "Installation finished" +yarn run build +echo "Building finished" +cd $ORIG_DIR +mv $FRONTEND_DIR/caprover-frontend/build ./dist-frontend + +sudo apt-get update && sudo apt-get install qemu-user-static +# docker run --rm --privileged multiarch/qemu-user-static --reset -p yes +docker run --rm --privileged tonistiigi/binfmt --install all +# export DOCKER_CLI_EXPERIMENTAL=enabled +docker buildx ls +docker buildx rm mybuilder || echo "mybuilder not found" +docker buildx create --name mybuilder +docker buildx use mybuilder + +# docker buildx build --platform linux/arm -t $IMAGE_NAME:$CAPROVER_VERSION -t $IMAGE_NAME:latest -f dockerfile-captain.edge --push . +docker buildx build --platform linux/amd64,linux/arm64,linux/arm -t $IMAGE_NAME:$CAPROVER_VERSION -t $IMAGE_NAME:latest -f dockerfile-captain.edge --push . + +# docker build -t $IMAGE_NAME:$CAPROVER_VERSION -t $IMAGE_NAME:latest -f dockerfile-captain.edge . +# docker push $IMAGE_NAME:latest +# docker push $IMAGE_NAME:$CAPROVER_VERSION