Skip to content

Commit

Permalink
fixes run_build_github_release_package after docker changes
Browse files Browse the repository at this point in the history
  • Loading branch information
iturgeon committed May 26, 2021
1 parent 64eb5c3 commit be40de2
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 42 deletions.
19 changes: 6 additions & 13 deletions .github/workflows/test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ jobs:
run: |
cd docker
docker-compose build --no-cache webserver app
- name: Push App Images
run: |
docker tag ucfopen/materia:app-dev ghcr.io/${{ github.repository_owner }}/materia:app-${{ github.sha }}
Expand All @@ -44,20 +45,12 @@ jobs:
docker push ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ github.sha }}
docker push ghcr.io/${{ github.repository_owner }}/materia:webserver-${{ steps.tag_name.outputs.GIT_TAG }}
release_package:
needs: ci_tests
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

# run_build_github_release_package.sh relies on the current git user info
- run: git config --global user.email "lst@ucf.edu"
- run: git config --global user.name "ucfcdl-robot"

- name: Build Packages
run: cd docker && ./run_build_github_release_package.sh
- name: Build Package
run: |
git config --global user.email "lst@ucf.edu"
git config --global user.name "ucfcdl-robot"
cd docker && ./run_build_github_release_package.sh ghcr.io/${{ github.repository_owner }}/materia:app-${{ steps.tag_name.outputs.GIT_TAG }}
- name: Upload to Release
uses: svenstaro/upload-release-action@v2
Expand Down
54 changes: 25 additions & 29 deletions docker/run_build_github_release_package.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,23 @@
# ex: no need to install node # or npm packages
# to build js - just include the js
#
# EX: ./run_build_release_package.sh
# EX: ./run_build_github_release_package.sh.sh ghcr.io/ucfopen/private-materia:app-v8.0.0
#######################################################
set -e


die () {
echo >&2 "$@"
exit 1
}

# exit without args
if [ $# -lt 1 ]; then
die "1 required argument: docker-image-name"
fi

DOCKER_IMAGE=$1

# declare files that should have been created
declare -a FILES_THAT_SHOULD_EXIST=(
"public/js/materia.enginecore.js"
Expand Down Expand Up @@ -48,16 +61,8 @@ do
EXCLUDE="$EXCLUDE --exclude=\"./$i\""
done

# store the docker compose command to shorten the following commands
DCTEST="docker-compose -f docker-compose.yml -f docker-compose.override.test.yml"

set -o xtrace

# # stop and remove docker containers
$DCTEST down --volumes --remove-orphans

$DCTEST pull --ignore-pull-failures app

# get rid of any left over package files
rm -rf clean_build_clone || true
rm -rf ../materia-pkg* || true
Expand All @@ -71,36 +76,28 @@ GITCOMMIT=$(cd clean_build_clone && git rev-parse HEAD)
GITREMOTE=$(git remote get-url origin)

# remove .git dir for slightly faster copy
rm -rf clean_build_clone/.git
rm -rf ./clean_build_clone/.git
rm -rf ./clean_build_clone/public
rm -rf ./clean_build_clone/fuel/app/config/asset_hash.json

# start a build container
$DCTEST run --no-deps -d --workdir /build/clean_build_clone --name materia-build app tail -f /dev/null

# copy the clean build clone into the container
docker cp ./clean_build_clone materia-build:/build

# clean up
rm -rf clean_build_clone || true

# install production node_modules
docker exec materia-build yarn install --frozen-lockfile --non-interactive --production
docker cp $(docker create --rm $DOCKER_IMAGE):/var/www/html/public ./clean_build_clone/public/
docker cp $(docker create --rm $DOCKER_IMAGE):/var/www/html/fuel/app/config/asset_hash.json ./clean_build_clone/fuel/app/config/asset_hash.json

# verify all files we expect to be created exist
for i in "${FILES_THAT_SHOULD_EXIST[@]}"
do
docker exec materia-build stat /build/clean_build_clone/$i
stat ./clean_build_clone/$i
done

# zip, excluding some files
docker exec materia-build bash -c "zip -r $EXCLUDE ../materia-pkg.zip ./"
zip -r $EXCLUDE ../materia-pkg.zip ./clean_build_clone/

# calulate hashes
MD5=$(docker exec materia-build md5sum ../materia-pkg.zip | awk '{ print $1 }')
SHA1=$(docker exec materia-build sha1sum ../materia-pkg.zip | awk '{ print $1 }')
SHA256=$(docker exec materia-build sha256sum ../materia-pkg.zip | awk '{ print $1 }')

# copy zip file from container to host
docker cp materia-build:/build/materia-pkg.zip ../materia-pkg.zip
MD5=$(md5sum ../materia-pkg.zip | awk '{ print $1 }')
SHA1=$(sha1sum ../materia-pkg.zip | awk '{ print $1 }')
SHA256=$(sha256sum ../materia-pkg.zip | awk '{ print $1 }')

# write build info file
echo "build_date: $DATE" > ../materia-pkg-build-info.yml
Expand All @@ -112,5 +109,4 @@ echo "sha1: $SHA1" >> ../materia-pkg-build-info.yml
echo "sha256: $SHA256" >> ../materia-pkg-build-info.yml
echo "md5: $MD5" >> ../materia-pkg-build-info.yml

# clean environment and configs
$DCTEST down --volumes --remove-orphans
rm -rf ./clean_build_clone

0 comments on commit be40de2

Please sign in to comment.