-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
From now on Travis CI will manage the build cycle driven by the build script, hopefully the current configuration will work for automatic "artifact" (pdf) releases from master branch as well.
- Loading branch information
1 parent
d4320ea
commit ec73484
Showing
4 changed files
with
82 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
language: generic | ||
sudo: required | ||
script: './build.sh' | ||
services: | ||
- docker | ||
before_deploy: ./build.sh ci-git-setup | ||
after_deploy: ./build.sh ci-git-push | ||
deploy: | ||
provider: releases | ||
api_key: $GH_TOKEN | ||
file: dist/jossemargt-resume.pdf | ||
skip_cleanup: true | ||
on: | ||
repo: jossemarGT/resume | ||
branch: master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
#!/bin/bash | ||
set -eo pipefail | ||
set -euo pipefail | ||
|
||
GOAL=${1-default} | ||
BUILD_DATE=$(date +%B\ %d,\ %Y) | ||
TITLE=$(sed -n -e "s/^title:[[:space:]]*'\([^']\+\).*'/\1/p" docs/configuration.yaml) | ||
|
||
## | ||
# Generates HTML page inside docs/ directory using RESUME.md file and Pandoc Docker | ||
# container | ||
generate_page () { | ||
|
@@ -15,23 +17,80 @@ generate_page () { | |
./RESUME.md docs/configuration.yaml | ||
} | ||
|
||
## | ||
# Bumps last modified date in pandoc template configuration | ||
bump_date () { | ||
# TODO: Bump only if RESUME.md has changed | ||
sed -i "s/date:.*/date: ${BUILD_DATE}/" docs/configuration.yaml | ||
} | ||
|
||
## | ||
# Generates PDF file inside dist/ directory using docs/index.html file and | ||
# wkhtmltopdf Docker container | ||
generate_pdf () { | ||
[ -d dist ] || mkdir dist | ||
echo ":: Generating ${TITLE} PDF" | ||
docker run -v "$(pwd)":/tmp/source -w /tmp/source --rm madnight/docker-alpine-wkhtmltopdf \ | ||
--title "${TITLE}" --page-size Letter --no-background \ | ||
--quiet --title "${TITLE}" --page-size Letter --no-background \ | ||
--print-media-type --viewport-size 520px \ | ||
docs/index.html dist/jossemargt-resume.pdf | ||
} | ||
|
||
######### CI Specific goals ######### | ||
|
||
## | ||
# Setup git client in CI environment | ||
git_setup () { | ||
if [[ -z $(git config --local user.name) ]]; then | ||
echo ':: Setup CI git user and email' | ||
git config --local user.name 'Deployment Bot' | ||
git config --local user.email '[email protected]' | ||
fi | ||
} | ||
|
||
## | ||
# Commit changes on `docs` directory and tags branch's head with current date | ||
git_tag_bump () { | ||
if [[ -z $(git --no-pager diff --numstat docs) ]]; then | ||
echo ":: Git bump -> docs directory didn't change. SKIPPED" | ||
return 0 | ||
fi | ||
|
||
git add docs | ||
git commit -m "Update GH Pages on ${BUILD_DATE}" | ||
git tag "$(date +'%Y%m%d')" | ||
} | ||
|
||
## | ||
# Push latest changes and tags (vendor specific implementation) | ||
git_publish () { | ||
set +x # Just in case | ||
if [[ $TRAVIS_EVENT_TYPE != 'pull_request' ]]; then | ||
echo ':: Git publish' | ||
# Push latest commit to master branch and the tag associated with it | ||
git push "https://${GH_TOKEN}:[email protected]/${TRAVIS_REPO_SLUG}" \ | ||
--quiet HEAD:master --tags | ||
return 0 | ||
fi | ||
echo ':: Git publish -> Nothing to do' | ||
} | ||
|
||
## | ||
# Using the functions defined above | ||
bump_date | ||
generate_page | ||
generate_pdf | ||
case "$GOAL" in | ||
ci-git-setup) | ||
git_setup | ||
git_tag_bump | ||
;; | ||
ci-git-push) | ||
git_publish # A fenced git push | ||
;; | ||
default) | ||
bump_date | ||
generate_page | ||
generate_pdf | ||
;; | ||
*) | ||
echo ":: Unrecognized goal '${GOAL}'. Nothing to do." | ||
;; | ||
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters