2021-12-14 11:25:38 -05:00
#!/bin/bash
2022-12-28 09:25:45 -08:00
####################################################################################################
2021-12-17 17:43:47 -05:00
#
2022-12-28 09:25:45 -08:00
# Calls github-pages executable to build the site using allowed plugins and supported configuration
2021-12-14 11:25:38 -05:00
#
2022-12-28 09:25:45 -08:00
####################################################################################################
2021-12-14 11:25:38 -05:00
SOURCE_DIRECTORY = ${ GITHUB_WORKSPACE } /$INPUT_SOURCE
DESTINATION_DIRECTORY = ${ GITHUB_WORKSPACE } /$INPUT_DESTINATION
PAGES_GEM_HOME = $BUNDLE_APP_CONFIG
2023-06-21 09:38:57 -04:00
GITHUB_PAGES_BIN = $PAGES_GEM_HOME /bin/github-pages
2021-12-14 11:25:38 -05:00
2023-06-29 17:15:58 -07:00
# Check if Gemfile's dependencies are satisfied or print a warning
2023-06-21 11:41:52 -04:00
if test -e " $SOURCE_DIRECTORY /Gemfile" && ! bundle check --dry-run --gemfile " $SOURCE_DIRECTORY /Gemfile" ; then
2023-09-14 11:38:04 -07:00
echo "::warning::The github-pages gem can't satisfy your Gemfile's dependencies. If you want to use a different Jekyll version or need additional dependencies, consider building Jekyll site with GitHub Actions: https://jekyllrb.com/docs/continuous-integration/github-actions/"
2022-12-21 17:16:23 -08:00
fi
2021-12-14 11:25:38 -05:00
# Set environment variables required by supported plugins
export JEKYLL_ENV = "production"
export JEKYLL_GITHUB_TOKEN = $INPUT_TOKEN
export PAGES_REPO_NWO = $GITHUB_REPOSITORY
2022-01-06 13:17:41 -08:00
export JEKYLL_BUILD_REVISION = $INPUT_BUILD_REVISION
2023-06-29 17:15:58 -07:00
export PAGES_API_URL = $GITHUB_API_URL
2021-12-14 11:25:38 -05:00
2021-12-27 14:45:57 -08:00
# Set verbose flag
2021-12-27 15:09:06 -08:00
if [ " $INPUT_VERBOSE " = 'true' ] ; then
2021-12-14 11:25:38 -05:00
VERBOSE = '--verbose'
2021-12-27 15:09:06 -08:00
else
VERBOSE = ''
2021-12-14 11:25:38 -05:00
fi
2021-12-27 14:45:57 -08:00
# Set future flag
2021-12-27 15:09:06 -08:00
if [ " $INPUT_FUTURE " = 'true' ] ; then
2021-12-27 14:45:57 -08:00
FUTURE = '--future'
2021-12-27 15:09:06 -08:00
else
FUTURE = ''
2021-12-27 14:45:57 -08:00
fi
2021-12-14 11:25:38 -05:00
2023-10-19 17:40:15 -07:00
{ cd " $PAGES_GEM_HOME " || { echo "::error::pages gem not found" ; exit 1; } ; }
2023-10-19 17:34:27 -07:00
# Run the command, capturing the output
build_output = " $( $GITHUB_PAGES_BIN build " $VERBOSE " " $FUTURE " --source " $SOURCE_DIRECTORY " --destination " $DESTINATION_DIRECTORY " ) "
# Capture the exit code
exit_code = $?
if [ $exit_code -ne 0 ] ; then
# Remove the newlines from the build_output as annotation not support multiline
error = $( echo " $build_output " | tr '\n' ' ' | tr -s ' ' )
echo "::error:: $error "
else
# Display the build_output directly
echo " $build_output "
fi
# Exit with the captured exit code
exit $exit_code